⊗mkLsBsMxU 18 of 42 menu

Using Mixins in SASS

After we declare a mixin, we call it with the @include directive, which must include the mixin name. It can also optionally contain parameters and styles. Let's look at an example:

@mixin mix{ width: 100px; height: 100px; } div { @include mix; padding: 4px; margin-top: 10px; }

Compilation result:

div { width: 100px; height: 100px; padding: 4px; margin-top: 10px; }

Mixins can also be called in the document root, but only if they do not describe rules and do not reference the parent. See the following example:

@mixin active { p { color: #161618; background-color: red; } } @include active;

After compilation we will see:

p { color: #161618; background-color: red; }

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

@mixin font { font-family:'Courier New', Courier, monospace; font-size: 12px; } #product-card { @include font; color: #090957; font-weight: 600px; }

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

@mixin style { color:#090957; } button, link { @include style; font-size: 10px; padding: 4px; }

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

@mixin active-text { font-size: 14px; font-weight: bold; text-decoration: underline; color: blue; } #product-card, .active, .content { @include active-text; padding: 4px; }

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

@mixin size { font-size: 14px; padding: 10px; margin: 4px; } @mixin color { color: #580909; background-color: #e9e5ab; } #product-card { @include size; @include color; width: 600px; }
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