Sass @mixin Rules
You are Here:
Sass @mixin Rules
@mixin
allows you to define styles that can be re-used throughout your stylesheet.
Sass @mixin Rules Without Parameter
Example
SASS TO CSS CONVERTER
// mixin act as a user-defined style
@mixin reset-ul{
margin: 0;
padding: 0;
font-size: 16px;
color: black;
list-style-type: none;
}
footer ul{
@include reset-ul;
}
Syntax
@mixin mixinName($a, $b){
// css property
};
Sass @mixin Rules With Parameter
Example
SASS TO CSS CONVERTER
// @mixin with arguments
@mixin reset-ul($a, $b) {
margin: 0;
padding: 0;
font-size: $a;
color: $b;
list-style-type: none;
}
footer ul{
@include reset-ul(20px, green);
}
Sass @mixin Rules With Optional Parameter
Example
SASS TO CSS CONVERTER
// @mixin with optional argument
@mixin reset-ul($a, $b: red) {
margin: 0;
padding: 0;
font-size: $a;
color: $b;
list-style-type: none;
}
footer ul{
@include reset-ul(20px);
}
Reminder
Hi Developers, we almost covered 99.1% of Sass Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in Sass.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.