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?
✗ Incorrect
Mixins let you reuse CSS code blocks, so you don't have to write the same styles again and again.
How do you include a mixin inside a CSS rule in Sass?
✗ Incorrect
You use '@include mixin-name;' to add the mixin's styles inside a selector.
What happens if you change a mixin's code?
✗ Incorrect
Changing a mixin updates all places where it is included, saving time and avoiding errors.
Can mixins accept values to customize styles?
✗ Incorrect
Mixins can take parameters to make styles flexible and reusable with different values.
Which of these is NOT a benefit of using mixins?
✗ Incorrect
Mixins help with code reuse and maintenance but do not fix browser bugs automatically.
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.