0
0
SASSmarkup~20 mins

Mixin libraries pattern 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 mixin usage?
Given the following SASS code, what CSS will be generated?
$color-primary: #3498db;

@mixin button-style($bg-color) {
  background-color: $bg-color;
  border: none;
  padding: 1rem 2rem;
  color: white;
  cursor: pointer;
}

.button {
  @include button-style($color-primary);
}
SASS
$color-primary: #3498db;

@mixin button-style($bg-color) {
  background-color: $bg-color;
  border: none;
  padding: 1rem 2rem;
  color: white;
  cursor: pointer;
}

.button {
  @include button-style($color-primary);
}
A
.button {
  background-color: #000000;
  border: none;
  padding: 1rem 2rem;
  color: white;
  cursor: pointer;
}
B
.button {
  background-color: #3498db;
  border: none;
  padding: 1rem 2rem;
  color: white;
  cursor: pointer;
}
C
.button {
  background-color: $color-primary;
  border: none;
  padding: 1rem 2rem;
  color: white;
  cursor: pointer;
}
D
.button {
  background-color: #3498db;
  border: 1px solid black;
  padding: 1rem 2rem;
  color: white;
  cursor: pointer;
}
Attempts:
2 left
💡 Hint
Remember that variables are replaced with their values when compiled.
🧠 Conceptual
intermediate
1:30remaining
Which statement best describes the purpose of mixin libraries in SASS?
Choose the best explanation for why developers use mixin libraries in SASS.
AThey compile CSS into binary code for faster browser rendering.
BThey automatically convert CSS to JavaScript for dynamic styling.
CThey allow reusing groups of CSS declarations with parameters to avoid repetition and improve maintainability.
DThey replace all CSS selectors with unique IDs to prevent conflicts.
Attempts:
2 left
💡 Hint
Think about how mixins help with writing CSS code.
selector
advanced
2:00remaining
What CSS selector is generated by this nested SASS mixin usage?
Given this SASS code, what is the full CSS selector for the nested styles?
@mixin card-style {
  border: 1px solid #ccc;
  padding: 1rem;
  .title {
    font-weight: bold;
  }
}

.article {
  @include card-style;
}
SASS
@mixin card-style {
  border: 1px solid #ccc;
  padding: 1rem;
  .title {
    font-weight: bold;
  }
}

.article {
  @include card-style;
}
A
.article {
  border: 1px solid #ccc;
  padding: 1rem;
}
.article .title {
  font-weight: bold;
}
B
.article {
  border: 1px solid #ccc;
  padding: 1rem;
}
.title {
  font-weight: bold;
}
C
.title {
  font-weight: bold;
}
.article {
  border: 1px solid #ccc;
  padding: 1rem;
}
D
.article.title {
  font-weight: bold;
  border: 1px solid #ccc;
  padding: 1rem;
}
Attempts:
2 left
💡 Hint
Nested selectors inside mixins become nested in the output CSS relative to where the mixin is included.
layout
advanced
2:00remaining
How does this SASS mixin help with responsive layout?
Examine this mixin and its usage. What is the main layout benefit it provides?
@mixin flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  @include flex-center;
  height: 100vh;
}
SASS
@mixin flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  @include flex-center;
  height: 100vh;
}
AIt fixes the container size to 100 pixels width and height.
BIt applies a grid layout with three equal columns.
CIt hides overflow content inside the container on small screens.
DIt centers content horizontally and vertically inside the container, adapting to different screen sizes.
Attempts:
2 left
💡 Hint
Think about what flexbox properties do for alignment.
accessibility
expert
2:30remaining
Which mixin usage improves accessibility by enhancing focus styles?
Consider these four SASS mixin usages for focus styles. Which one best improves keyboard accessibility by making focus visible and clear?
@mixin focus-style-a {
  outline: none;
}

@mixin focus-style-b {
  outline: 2px solid blue;
  outline-offset: 2px;
}

@mixin focus-style-c {
  border: 1px solid transparent;
}

@mixin focus-style-d {
  box-shadow: 0 0 0 3px rgba(21, 156, 228, 0.4);
}
SASS
@mixin focus-style-a {
  outline: none;
}

@mixin focus-style-b {
  outline: 2px solid blue;
  outline-offset: 2px;
}

@mixin focus-style-c {
  border: 1px solid transparent;
}

@mixin focus-style-d {
  box-shadow: 0 0 0 3px rgba(21, 156, 228, 0.4);
}
AUsing @include focus-style-b to add a visible blue outline with offset.
BUsing @include focus-style-a to remove outlines for a cleaner look.
CUsing @include focus-style-c to add a transparent border that does not show on focus.
DUsing @include focus-style-d to add a subtle blue glow around focused elements.
Attempts:
2 left
💡 Hint
Good focus styles must be visible and distinct for keyboard users.