⊗mkLsBsMxP 19 of 42 menu

Mixin Parameters in SASS

An important feature of mixins in SASS is that they accept variables as parameters, which are written inside parentheses and, if there are several variables, they are separated by commas.

Let's consider the following example:

@mixin active($color, $width) { border: { color: $color; width: $width; style: dotted; } } p { @include active(yellow, 2px); }

Compilation result:

p { border-color: yellow; border-width: 2px; border-style: dashed; }

In addition, you can pass default parameter values ​​to mixins:

@mixin active($color, $width: 2px) { border: { color: $color; width: $width; style: dotted; } } p { @include active(yellow); } div { @include active(yellow, 4px); }

After compilation we will see:

p { border-color: yellow; border-width: 2px; border-style: dotted; } div { border-color: yellow; border-width: 4px; border-style: dotted; }

Tell me what the result of compiling the following code will be:

@mixin simple-border($padding-top, $padding-bottom) { border: { padding-top: $padding-top; padding-bottom: $padding-bottom; color: green; } } p { @include simple-border(10px, 30px ); }

Tell me what the result of compiling the following code will be:

@mixin simple-border($padding-top, $padding-bottom: 20px) { border: { padding-top: $padding-top; padding-bottom: $padding-bottom; color: green; } } p { @include simple-border(10px); }
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline