0
0
SASSmarkup~5 mins

Why mixins eliminate duplication in SASS - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What is a mixin in Sass?
A mixin is a reusable block of styles that you can include in other selectors to avoid repeating the same CSS code.
Click to reveal answer
beginner
How do mixins help eliminate duplication?
Mixins let you write styles once and reuse them many times, so you don’t have to copy and paste the same code in multiple places.
Click to reveal answer
beginner
Show a simple example of a mixin in Sass.
@mixin center { display: flex; justify-content: center; align-items: center; } .box { @include center; height: 100px; width: 100px; background-color: lightblue; }
Click to reveal answer
beginner
Why is using mixins better than copying styles?
Using mixins keeps your code clean and easier to update. If you change the mixin, all places using it update automatically.
Click to reveal answer
intermediate
Can mixins accept parameters? Why is this useful?
Yes, mixins can take parameters to customize styles each time you use them, making them flexible and reducing duplication even more.
Click to reveal answer
What does a Sass mixin help you avoid?
AWriting HTML tags
BRepeating the same CSS code multiple times
CUsing JavaScript functions
DAdding images to a webpage
How do you include a mixin inside a CSS rule in Sass?
A@include mixin-name;
B@mixin mixin-name;
Cinclude(mixin-name);
Duse mixin-name;
What happens if you change a mixin's code?
AOnly the first selector using it updates
BYou must manually update each selector
CAll selectors using it update automatically
DNothing changes
Can mixins accept values to customize styles?
AYes, they can take parameters
BNo, they are fixed blocks
COnly in CSS, not Sass
DOnly if you use JavaScript
Which of these is NOT a benefit of using mixins?
AReducing code duplication
BMaking code easier to maintain
CCustomizing styles with parameters
DAutomatically fixing browser bugs
Explain in your own words how mixins help reduce repeated CSS code.
Think about writing a style once and using it many times.
You got /4 concepts.
    Describe how parameters in mixins make them more flexible.
    Imagine changing colors or sizes each time you use the same mixin.
    You got /4 concepts.