Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the main purpose of Flexbox utility classes in CSS?
Flexbox utility classes help quickly apply common flexbox properties like layout direction, alignment, and spacing without writing custom CSS each time.
Click to reveal answer
intermediate
In Sass, how can you generate multiple utility classes for flexbox properties efficiently?
You can use Sass loops like @each or @for to create classes dynamically by iterating over lists or maps of property values.
Click to reveal answer
beginner
What does the following Sass snippet do?
@each $dir in row, column {
.flex-#{$dir} {
display: flex;
flex-direction: $dir;
}
}
It creates two classes: .flex-row and .flex-column. Each sets display to flex and flex-direction to row or column respectively.
Click to reveal answer
beginner
Why is it helpful to generate flexbox utility classes with Sass instead of writing each class manually?
It saves time, reduces errors, and keeps code consistent and easy to update by changing values in one place.
Click to reveal answer
beginner
Name three common flexbox properties you might include in utility classes.
flex-direction, justify-content, align-items
Click to reveal answer
Which Sass directive is best for creating multiple similar flexbox utility classes?
A@each
B@if
C@mixin
D@extend
✗ Incorrect
@each lets you loop over a list of values to generate classes for each flexbox property variation.
What CSS property does the class .flex-row typically set?
Aflex-direction: row
Bjustify-content: center
Calign-items: flex-start
Ddisplay: block
✗ Incorrect
.flex-row sets flex-direction to row to arrange items horizontally.
Why use utility classes for flexbox instead of writing styles inline or in separate CSS rules?
AThey increase CSS file size unnecessarily
BThey only work in old browsers
CThey prevent responsive design
DThey allow quick reuse and consistent styling across the site
✗ Incorrect
Utility classes promote reuse and consistency, making styling faster and easier.
Which Sass feature helps keep utility class code DRY (Don't Repeat Yourself)?
AVariables only
BLoops like @each
CComments
DPlain CSS
✗ Incorrect
Loops let you write code once and generate many classes, avoiding repetition.
What is the visual effect of applying .flex-center utility class that sets justify-content and align-items to center?
AItems overflow outside the container
BItems are aligned to the left
CItems are centered horizontally and vertically inside the container
DItems stack vertically with space between
✗ Incorrect
Centering both horizontally and vertically aligns items in the middle of the flex container.
Explain how you would use Sass to generate utility classes for flexbox directions and alignments.
Think about looping over lists of property values and combining them into class names.
You got /4 concepts.
Describe the benefits of using flexbox utility classes generated by Sass in a web project.
Consider how utility classes improve workflow and code quality.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of generating Flexbox utility classes using SASS?
easy
A. To disable Flexbox features in the browser
B. To write long CSS rules for each Flexbox property manually
C. To convert Flexbox layouts into grid layouts automatically
D. To create small reusable classes that quickly arrange items with Flexbox
Solution
Step 1: Understand Flexbox utility classes
Flexbox utility classes are small CSS classes that help arrange items quickly using Flexbox properties.
Step 2: Role of SASS in generating these classes
SASS mixins automate creating these reusable classes, saving time and keeping code neat.
Final Answer:
To create small reusable classes that quickly arrange items with Flexbox -> Option D
Quick Check:
Flexbox utility classes = reusable small classes [OK]
Hint: Think: reusable small classes for layout with Flexbox [OK]
Common Mistakes:
Confusing utility classes with full component styles
Thinking SASS disables Flexbox
Assuming SASS converts Flexbox to grid automatically
2. Which SASS syntax correctly defines a mixin to generate a flex container with customizable direction?
easy
A. @mixin flex-container($direction) { display: flex; flex-direction: $direction; }
B. @function flex-container($direction) { display: flex; flex-direction: $direction; }
C. @include flex-container($direction) { display: flex; flex-direction: $direction; }
D. @extend flex-container($direction) { display: flex; flex-direction: $direction; }
Solution
Step 1: Identify correct SASS mixin syntax
A mixin is defined with '@mixin name(parameters) { ... }'.
Step 2: Check options for correct usage
@mixin flex-container($direction) { display: flex; flex-direction: $direction; } uses '@mixin' correctly; others use '@function', '@include', or '@extend' incorrectly for definition.
A. Missing semicolon after 'align-items: $align' property
B. Incorrect mixin name 'flex-align' instead of 'flex-align-items'
C. Wrong property 'align-items' should be 'justify-content'
D. Mixin call '@include flex-align(center)' is invalid syntax
Solution
Step 1: Check CSS property syntax inside mixin
CSS properties must end with a semicolon; here 'align-items: $align' misses it.
Step 2: Verify mixin usage and names
Mixin name and call are correct; property name is valid for alignment.
Final Answer:
Missing semicolon after 'align-items: $align' property -> Option A
Quick Check:
CSS properties need semicolons [OK]
Hint: Always end CSS declarations with semicolons [OK]
Common Mistakes:
Omitting semicolons after CSS properties
Confusing align-items with justify-content
Incorrect mixin call syntax
5. You want to generate utility classes for flex direction (row, column) and justify-content (start, center, end) using SASS loops. Which SASS code correctly creates classes like .flex-row-start and .flex-column-center?
hard
A. @mixin flex-utility($direction, $justify) { display: flex; flex-direction: $direction; justify-content: $justify; }
@for $i from 1 through 2 {
@for $j from 1 through 3 {
.flex-#{$i}-#{$j} {
@include flex-utility($i, $j);
}
}
}
B. @mixin flex-utility($direction, $justify) { display: flex; flex-direction: $direction; justify-content: $justify; }
@each $dir in (row, column) {
@each $just in (start, center, end) {
.flex-#{$dir}-#{$just} {
@include flex-utility($dir, $just);
}
}
}
D. @mixin flex-utility($direction, $justify) { display: flex; flex-direction: $direction; justify-content: $justify; }
@each $just in (start, center, end) {
.flex-#{$just} {
@include flex-utility(row, $just);
}
}
Solution
Step 1: Understand the goal of generating combined classes
We want classes combining direction and justify-content, e.g., .flex-row-start.
Step 2: Check each option for correct nested loops and class naming
@mixin flex-utility($direction, $justify) { display: flex; flex-direction: $direction; justify-content: $justify; }
@each $dir in (row, column) {
@each $just in (start, center, end) {
.flex-#{$dir}-#{$just} {
@include flex-utility($dir, $just);
}
}
} uses nested @each loops over directions and justifications, correctly generating combined class names and including the mixin with proper parameters.
Step 3: Identify why other options fail
@mixin flex-utility($direction, $justify) { display: flex; flex-direction: $direction; justify-content: $justify; }
@for $i from 1 through 2 {
@for $j from 1 through 3 {
.flex-#{$i}-#{$j} {
@include flex-utility($i, $j);
}
}
} uses numeric loops without mapping to direction names; C and D generate only partial combinations.
Final Answer:
Nested @each loops generating .flex-#{$dir}-#{$just} classes -> Option B