0
0
SASSmarkup~5 mins

Media query mixin patterns in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AEnds the mixin
BDefines a new variable
CStarts a media query
DInserts the CSS rules passed to the mixin
Which of these is a correct way to write a media query mixin for max-width 768px?
A@mixin mq { @media (max-width: 768px) { @content; } }
B@mixin mq { max-width: 768px { @content; } }
C@mixin mq { @media max-width: 768px { @content; } }
D@mixin mq { @media (min-width: 768px) { @content; } }
Why are media query mixins helpful in Sass?
AThey allow reusing media queries easily
BThey make CSS slower
CThey replace HTML tags
DThey remove the need for CSS
How do you include a mixin named 'mobile' in Sass?
A@use mobile;
B@import mobile;
C@include mobile;
D@mixin mobile;
What is the main advantage of naming media query mixins like 'small-screen' or 'tablet'?
AMakes CSS load faster
BMakes code easier to understand and maintain
CChanges HTML structure
DRemoves the need for media queries
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.