0
0
SASSmarkup~20 mins

Including mixins with @include in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Mixin 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 code?
Given the Sass code below, what CSS will be generated after compilation?
SASS
@mixin fancy-text {
  color: red;
  font-weight: bold;
}

.title {
  @include fancy-text;
  font-size: 2rem;
}
A
.title {
  color: red;
  font-weight: bold;
  font-size: 2rem;
}
B
.title {
  font-size: 2rem;
}

.fancy-text {
  color: red;
  font-weight: bold;
}
C
.fancy-text {
  color: red;
  font-weight: bold;
}

.title {
  font-size: 2rem;
}
D
.title {
  color: red;
  font-size: 2rem;
}
Attempts:
2 left
💡 Hint
Remember that @include inserts the mixin's styles inside the selector where it is called.
🧠 Conceptual
intermediate
2:00remaining
What happens if you include a mixin with parameters incorrectly?
Consider this mixin with a parameter: @mixin box-shadow($shadow) { box-shadow: $shadow; } Which option will cause an error when including this mixin?
A
.card {
  @include box-shadow;
}
B
.card {
  @include box-shadow(2px 2px 5px gray);
}
C
.card {
  @include box-shadow('2px 2px 5px gray');
}
D
.card {
  @include box-shadow($shadow: 2px 2px 5px gray);
}
Attempts:
2 left
💡 Hint
Mixins with parameters require you to pass arguments when including.
selector
advanced
2:00remaining
Which option correctly includes a mixin inside a nested selector?
Given this Sass code, which option produces the correct CSS output?
SASS
@mixin highlight {
  background-color: yellow;
}

.article {
  p {
    @include highlight;
  }
}
A
.article {
  p {
    background-color: yellow;
  }
}
B
.article p {
  background-color: yellow;
}
C
p {
  background-color: yellow;
}
D
.highlight {
  background-color: yellow;
}
Attempts:
2 left
💡 Hint
Nested selectors in Sass compile to combined selectors in CSS.
layout
advanced
2:00remaining
How does including a mixin affect layout styles in this example?
Look at this Sass code with a mixin for flexbox layout: @mixin flex-center { display: flex; justify-content: center; align-items: center; } .container { @include flex-center; height: 10rem; } What will the container look like in the browser?
AA box with no height and content centered horizontally only.
BA box 10rem tall with content aligned to the left and top by default.
CA box 10rem tall with content centered horizontally and vertically using flexbox.
DA box 10rem tall with content stacked vertically but not centered.
Attempts:
2 left
💡 Hint
Flexbox with justify-content and align-items set to center centers content both ways.
accessibility
expert
2:00remaining
Which mixin inclusion best supports accessible focus styles?
You have this mixin for focus styles: @mixin focus-ring { outline: 3px solid blue; outline-offset: 2px; } Which option correctly includes this mixin to improve keyboard accessibility on buttons?
A
button:hover {
  @include focus-ring;
}
B
button {
  @include focus-ring;
}
C
button:active {
  @include focus-ring;
}
D
button:focus {
  @include focus-ring;
}
Attempts:
2 left
💡 Hint
Focus styles should apply only when the element receives keyboard focus.