0
0
SASSmarkup~20 mins

Flexbox utility class generation in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flexbox Utility Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the output CSS of this SASS snippet?
Given this SASS code, what CSS does it generate?
$directions: row column;
.flex-container {
display: flex;
@each $dir in $directions {
&-#{$dir} {
flex-direction: $dir;
}
}
}
SASS
$directions: row column;
.flex-container {
  display: flex;
  @each $dir in $directions {
    &-#{$dir} {
      flex-direction: $dir;
    }
  }
}
A
.flex-container-row { flex-direction: row; }
.flex-container-column { flex-direction: column; }
.flex-container { display: flex; }
B
.flex-container { display: flex; }
.flex-container-row { flex-direction: column; }
.flex-container-column { flex-direction: row; }
C
.flex-container-row { display: flex; flex-direction: row; }
.flex-container-column { display: flex; flex-direction: column; }
D
.flex-container { display: flex; }
.flex-container-row { flex-direction: row; }
.flex-container-column { flex-direction: column; }
Attempts:
2 left
💡 Hint
Look at how the @each loop creates classes with suffixes from the list.
🧠 Conceptual
intermediate
1:30remaining
Which flex-wrap utility class allows wrapping items to the next line?
You want a utility class that sets flex-wrap to wrap items onto multiple lines. Which class name and property pairing is correct?
A.flex-wrap { flex-wrap: wrap; }
B.flex-nowrap { flex-wrap: wrap; }
C.flex-wrap { flex-wrap: nowrap; }
D.flex-nowrap { flex-wrap: nowrap; }
Attempts:
2 left
💡 Hint
Remember: 'wrap' means items can move to next line, 'nowrap' means stay on one line.
selector
advanced
2:30remaining
Which SASS selector correctly generates responsive flex-direction classes?
You want to create flex-direction utility classes for mobile and desktop using SASS variables:
$directions: row column;
$breakpoints: mobile desktop;
.flex {
@each $bp in $breakpoints {
@each $dir in $directions {
&-#{$bp}-#{$dir} {
flex-direction: $dir;
}
}
}
}

Which option shows the correct CSS output for these classes?
SASS
$directions: row column;
$breakpoints: mobile desktop;
.flex {
  @each $bp in $breakpoints {
    @each $dir in $directions {
      &-#{$bp}-#{$dir} {
        flex-direction: $dir;
      }
    }
  }
}
A
.flex-mobile-row { flex-direction: column; }
.flex-mobile-column { flex-direction: row; }
.flex-desktop-row { flex-direction: column; }
.flex-desktop-column { flex-direction: row; }
B
.flex-mobile-row { flex-direction: row; }
.flex-mobile-column { flex-direction: column; }
.flex-desktop-row { flex-direction: row; }
.flex-desktop-column { flex-direction: column; }
C
.flex-mobile { flex-direction: row; }
.flex-desktop { flex-direction: column; }
D
.flex-row-mobile { flex-direction: row; }
.flex-column-mobile { flex-direction: column; }
.flex-row-desktop { flex-direction: row; }
.flex-column-desktop { flex-direction: column; }
Attempts:
2 left
💡 Hint
Look at how the class names combine breakpoint and direction in the order: flex-#{$bp}-#{$dir}.
layout
advanced
1:30remaining
What visual layout results from this flexbox utility class?
Consider this CSS class:
.flex-center {
display: flex;
justify-content: center;
align-items: center;
}

What will you see when this class is applied to a container with multiple child boxes?
AChild boxes are arranged vertically, spaced evenly with gaps.
BChild boxes are stacked vertically at the top-left corner.
CChild boxes are arranged horizontally, aligned to the left and bottom edges.
DChild boxes are arranged horizontally, centered both vertically and horizontally inside the container.
Attempts:
2 left
💡 Hint
justify-content centers items along the main axis, align-items centers along the cross axis.
accessibility
expert
2:00remaining
Which ARIA role best improves accessibility for a flexbox container used as a navigation menu?
You have a flex container that holds navigation links styled with flexbox. Which ARIA role attribute should you add to the container to help screen readers understand its purpose?
Arole="contentinfo"
Brole="main"
Crole="navigation"
Drole="banner"
Attempts:
2 left
💡 Hint
Think about the semantic meaning of navigation menus for assistive technologies.