Recall & Review
beginner
What is the purpose of state classes like
:hover, :active, and :disabled in CSS/Sass?They define how elements look or behave when users interact with them, such as when hovering with a mouse, clicking, or when an element is disabled and not interactive.
Click to reveal answer
intermediate
How can you generate multiple state classes in Sass efficiently?
By using Sass features like
@each loops and mixins to write reusable code that applies styles for each state without repeating code.Click to reveal answer
beginner
What does the
& symbol represent in Sass when used inside a nested selector?It refers to the parent selector, allowing you to append pseudo-classes or other selectors to the current selector.
Click to reveal answer
intermediate
Write a simple Sass mixin to generate styles for
:hover, :active, and :disabled states.A mixin can loop through states and apply styles like this:<br>
@mixin states($states) {
@each $state in $states {
&:#{$state} {
// styles here
}
}
}
// Usage:
.button {
@include states((hover, active, disabled));
}
Click to reveal answer
beginner
Why is it important to style the
:disabled state differently?Because disabled elements should look inactive and not respond to user actions, helping users understand they cannot interact with them.
Click to reveal answer
Which Sass feature helps you write styles for multiple states without repeating code?
✗ Incorrect
The @each loop lets you iterate over a list of states and apply styles for each, avoiding repetition.
In Sass, what does the selector
&:hover mean inside a nested block?✗ Incorrect
The & refers to the parent selector, so &:hover applies styles when the parent is hovered.
Which state class should visually indicate that an element cannot be interacted with?
✗ Incorrect
The :disabled state shows that an element is inactive and not interactive.
What is the main benefit of using a Sass mixin for state classes?
✗ Incorrect
Mixins help reuse code and keep styles consistent across different states.
Which of these is NOT a common state class in CSS/Sass?
✗ Incorrect
:loading is not a standard CSS state; :hover, :active, and :disabled are common.
Explain how you would use Sass to create styles for hover, active, and disabled states without repeating code.
Think about looping through states and nesting selectors.
You got /4 concepts.
Why is it important to visually differentiate the disabled state from hover and active states in a web interface?
Consider how users understand what they can or cannot click.
You got /4 concepts.