0
0
SASSmarkup~20 mins

Why advanced mixins solve complex problems in SASS - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Advanced Sass Mixins Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main benefit of using advanced mixins in Sass?

Why do advanced mixins help solve complex styling problems in Sass?

AThey allow reusing complex style patterns with parameters to customize output.
BThey automatically convert CSS to JavaScript for dynamic styling.
CThey replace all CSS selectors with inline styles in HTML.
DThey remove the need for variables by hardcoding values everywhere.
Attempts:
2 left
💡 Hint

Think about how you can reuse code with small changes.

📝 Syntax
intermediate
2:00remaining
What is the output CSS of this Sass mixin usage?

Given this Sass code, what CSS will it produce?

SASS
@mixin box-shadow($x, $y, $blur, $color) {
  -webkit-box-shadow: $x $y $blur $color;
  box-shadow: $x $y $blur $color;
}

.card {
  @include box-shadow(2px, 4px, 6px, rgba(0,0,0,0.3));
}
A
.card {
  -webkit-box-shadow: 2px 4px 6px rgba(0,0,0,0.6);
  box-shadow: 2px 4px 6px rgba(0,0,0,0.6);
}
B
.card {
  -webkit-box-shadow: 2px 4px 6px rgba(0,0,0,0.3);
  box-shadow: 2px 4px 6px rgba(0,0,0,0.3);
}
C
.card {
  -webkit-box-shadow: 2px 4px 6px #000000;
  box-shadow: 2px 4px 6px #000000;
}
D
.card {
  box-shadow: 2px 4px 6px rgba(0,0,0,0.3);
}
Attempts:
2 left
💡 Hint

Look carefully at the rgba color and values passed to the mixin.

selector
advanced
2:00remaining
Which option correctly uses a mixin to style nested selectors?

How do you use a mixin to apply styles to nested selectors in Sass?

SASS
@mixin button-styles {
  background-color: blue;
  color: white;
  &:hover {
    background-color: darkblue;
  }
}

.btn {
  @include button-styles;
}
A
.btn {
  background-color: blue;
  color: white;
}
.btn:hover {
  background-color: darkblue;
}
B
.btn {
  background-color: blue;
  color: white;
  &:hover {
    background-color: darkblue;
  }
}
C
.btn {
  background-color: blue;
  color: white;
}
:hover {
  background-color: darkblue;
}
D
.btn {
  background-color: blue;
  color: white;
}
.btn:hover {
  color: darkblue;
}
Attempts:
2 left
💡 Hint

Remember how Sass compiles nested selectors.

layout
advanced
2:00remaining
How can advanced mixins help create responsive layouts?

Which mixin usage best helps create a responsive grid layout with customizable columns?

SASS
@mixin responsive-grid($cols) {
  display: grid;
  grid-template-columns: repeat($cols, 1fr);
  gap: 1rem;
  @media (max-width: 600px) {
    grid-template-columns: 1fr;
  }
}

.container {
  @include responsive-grid(3);
}
A
.container {
  display: block;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 600px) {
  .container {
    grid-template-columns: 1fr;
  }
}
B
.container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
@media (max-width: 600px) {
  .container {
    flex-direction: column;
  }
}
C
.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 600px) {
  .container {
    grid-template-columns: 1fr;
  }
}
D
.container {
  display: grid;
  grid-template-columns: 3fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .container {
    grid-template-columns: 1fr;
  }
}
Attempts:
2 left
💡 Hint

Look for the correct grid display and media query usage.

accessibility
expert
2:00remaining
Which mixin usage best supports accessible focus styles?

How can you use an advanced mixin to ensure consistent and visible focus outlines for keyboard users?

SASS
@mixin focus-visible-outline($color: blue, $width: 3px) {
  outline: none;
  &:focus-visible {
    outline: $width solid $color;
    outline-offset: 2px;
  }
}

.button {
  @include focus-visible-outline(red);
}
A
.button {
  outline: none;
}
.button:focus {
  outline: 3px solid red;
  outline-offset: 2px;
}
B
.button {
  outline: 3px solid red;
  outline-offset: 2px;
}
.button:focus-visible {
  outline: none;
}
C
.button {
  outline: none;
  outline-offset: 2px;
}
.button:focus {
  outline: 3px solid red;
}
D
.button {
  outline: none;
}
.button:focus-visible {
  outline: 3px solid red;
  outline-offset: 2px;
}
Attempts:
2 left
💡 Hint

Focus-visible only shows outline when keyboard focusing, not mouse.