Sass Mixin for Links

Developer
Size
3,743 Kb
Views
14,168

How do I make an sass mixin for links?

A simple mixin that "forces" you to declare the 4 states of links: - :link, :visited, :hover and :active.. What is a sass mixin for links? How do you make a sass mixin for links? This script and codes were developed by Ricardo Zea on 28 September 2022, Wednesday.

Sass Mixin for Links Previews

Sass Mixin for Links - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Sass Mixin for Links</title> <link rel='stylesheet prefetch' href='css/https___s3_us_west_2_amaz.css'>
<link rel='stylesheet prefetch' href='https://s3-us-west-2.amazonaws.com/s.cdpn.io/9988/highlight.min-9.1.0.css'>
<link rel='stylesheet prefetch' href='https://s3-us-west-2.amazonaws.com/s.cdpn.io/9988/highlight-theme-monokai-sublime.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Sass Mixin for Links</h1>
<a href="#">This is a link</a>
<hr />
<p>The idea behind this mixin is that no defaults are declared in the arguments so that we are “forced” in a friendly way to declare all 4 states of our links.</p>
<p>The <code>:focus</code> and <code>:active</code> pseudo-classes are usually declared together. Feel free to separate them if you want to do so.</p>
<p>One note about this mixin, is that it can be applied to any HTML element, not only links.</p>
<hr />
<h2>Mixin:</h2>
<pre><code class="css">@mixin links ($link, $visited, $hover, $active) { & { color: $link; &:visited { color: $visited; } &:hover { color: $hover; } &:active, &:focus { color: $active; } }
}
</code></pre>
<h2>Usage:</h2>
<pre><code class="css">a { @include links(orange, blue, yellow, teal);
}</code></pre>
<h2>Compiles to:</h2>
<pre><code class="css">a { color: orange;
}
a:visited { color: blue;
}
a:hover { color: yellow;
}
a:active, a:focus { color: teal;
}</code></pre> <script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/9988/highlight.min-9.1.0.js'></script> <script src="js/index.js"></script>
</body>
</html>

Sass Mixin for Links - Script Codes CSS Codes

a { color: orange;
}
a:visited { color: blue;
}
a:hover { color: yellow;
}
a:active, a:focus { color: teal;
}
a { padding: 4px 10px; font-size: 20px; background: #444;
}
pre, code, p { text-align: left;
}
code { background: none; box-shadow: none; font-size: 18px;
}
h2 { text-align: left;
}
* { font-weight: normal !important;
}

Sass Mixin for Links - Script Codes JS Codes

/*Highlight.JS
https://highlightjs.org/
*/
hljs.initHighlightingOnLoad();
Sass Mixin for Links - Script Codes
Sass Mixin for Links - Script Codes
Home Page Home
Developer Ricardo Zea
Username ricardozea
Uploaded September 28, 2022
Rating 4
Size 3,743 Kb
Views 14,168
Do you need developer help for Sass Mixin for Links?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Ricardo Zea (ricardozea) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!