Sass @function Rules
You are Here:
Sass @function Rules
@function
allows you to define complex operations on SassScript values that you can re-use throughout your stylesheet.
Note: Each @function
must end with a @return
.
Sass @function With Parameter
Example
SASS TO CSS CONVERTER
@function myFunction($x){
$result: $x * 2;
@return $result;
}
footer ul{
font-size: myFunction(8) * 1px;
}
Syntax
@function functionName($a, $b){
// function block
};
Sass @function With Optional Parameter
Example
SASS TO CSS CONVERTER
@function myFunction($x, $mul: 2){
$result: $x * $mul;
@return $result;
}
footer ul{
// try myFunction(8, 3)
font-size: myFunction(8) * 1px;
}
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.