Recall & Review
beginner
What is a media query mixin in Sass?
A media query mixin in Sass is a reusable block of code that helps you write media queries easily by wrapping CSS rules inside a function-like structure. It makes your styles cleaner and easier to maintain.
Click to reveal answer
beginner
How do you define a simple media query mixin for a max-width of 600px?
@mixin max-width-600 {
@media (max-width: 600px) {
@content;
}
}
This mixin wraps any CSS passed inside it with a max-width 600px media query.
Click to reveal answer
intermediate
Why use media query mixins instead of writing media queries directly?
Using mixins avoids repeating the same media query code. It keeps your CSS DRY (Don't Repeat Yourself), makes updates easier, and improves readability by giving meaningful names to breakpoints.
Click to reveal answer
intermediate
Show an example of a responsive font size using a media query mixin.
@mixin respond-to($breakpoint) {
@if $breakpoint == small {
@media (max-width: 600px) {
@content;
}
}
}
p {
font-size: 1.6rem;
@include respond-to(small) {
font-size: 1.2rem;
}
}
This changes paragraph font size on small screens.
Click to reveal answer
beginner
What is the role of @content inside a Sass mixin for media queries?
@content is a placeholder inside a mixin where you put the CSS rules that should be wrapped by the media query. It lets you insert custom styles when you use the mixin.
Click to reveal answer
What does the @content directive do inside a Sass mixin?
✗ Incorrect
@content inserts the CSS rules you write inside the mixin call, wrapping them as needed.
Which of these is a correct way to write a media query mixin for max-width 768px?
✗ Incorrect
Option A correctly uses @media with parentheses and @content inside the mixin.
Why are media query mixins helpful in Sass?
✗ Incorrect
Mixins help reuse media queries, making code cleaner and easier to update.
How do you include a mixin named 'mobile' in Sass?
✗ Incorrect
You use @include followed by the mixin name to apply it.
What is the main advantage of naming media query mixins like 'small-screen' or 'tablet'?
✗ Incorrect
Meaningful names help you and others know what screen size the styles target.
Explain how to create and use a media query mixin in Sass for responsive design.
Think about wrapping CSS inside a function-like block that applies only on certain screen sizes.
You got /4 concepts.
Describe the benefits of using media query mixins compared to writing media queries directly in your Sass files.
Consider how repeating the same media query over and over can be avoided.
You got /4 concepts.