0
0
SASSmarkup~20 mins

Container and wrapper patterns in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container and Wrapper Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding container max-width behavior
Given a container with a max-width set in Sass, what happens when the viewport width is smaller than the max-width?
SASS
$container-max-width: 60rem;
.container {
  max-width: $container-max-width;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}
AThe container width shrinks to fit the viewport width minus padding, never exceeding 60rem.
BThe container width stays fixed at 60rem regardless of viewport size, causing horizontal scroll on small screens.
CThe container width becomes zero when viewport is smaller than 60rem.
DThe container width expands beyond 60rem to fill the viewport.
Attempts:
2 left
💡 Hint
Think about how max-width and auto margins work together in CSS.
📝 Syntax
intermediate
1:30remaining
Identify the correct Sass syntax for a wrapper with padding
Which Sass code correctly defines a wrapper class with 2rem padding on all sides and a background color of light gray?
A
.wrapper {
  padding: 2rem;
  background-color: #d3d3d3;
}
B
.wrapper {
  padding: 2rem;
  background: lightgray;
}
C
.wrapper {
  padding: 2rem;
  background-color: lightgray;
}
D
.wrapper {
  padding: 2rem
  background-color: #d3d3d3;
}
Attempts:
2 left
💡 Hint
Check for missing semicolons and valid CSS properties.
selector
advanced
2:00remaining
Which selector targets only direct child containers inside a wrapper?
Given the HTML structure below, which Sass selector targets only the direct .container children of .wrapper?
SASS
<div class="wrapper">
  <div class="container">Direct child</div>
  <div>
    <div class="container">Nested container</div>
  </div>
</div>
A.wrapper ~ .container { color: blue; }
B.wrapper .container { color: blue; }
C.wrapper + .container { color: blue; }
D.wrapper > .container { color: blue; }
Attempts:
2 left
💡 Hint
Think about CSS combinators that select direct children only.
layout
advanced
2:00remaining
How to center a container horizontally with Sass and Flexbox?
Which Sass code snippet correctly centers a container horizontally inside a wrapper using Flexbox?
A
.wrapper {
  display: flex;
  justify-content: flex-start;
}
.container {
  width: 50rem;
}
B
.wrapper {
  display: flex;
  align-items: center;
}
.container {
  width: 50rem;
}
C
.wrapper {
  display: flex;
  justify-content: center;
}
.container {
  width: 50rem;
}
D
.wrapper {
  display: block;
  margin: 0 auto;
}
.container {
  width: 50rem;
}
Attempts:
2 left
💡 Hint
Remember that justify-content controls horizontal alignment in Flexbox.
accessibility
expert
2:30remaining
Ensuring accessible focus within container and wrapper patterns
Which Sass approach best supports keyboard accessibility by visually indicating focus inside a container wrapper pattern?
A
.container:focus {
  background-color: #eee;
}
B
.container:focus-within {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}
C
.wrapper:hover {
  border: 2px solid #005fcc;
}
D
.container:active {
  box-shadow: 0 0 5px #005fcc;
}
Attempts:
2 left
💡 Hint
Focus indication should appear when any child element inside the container has focus.