0
0
SASSmarkup~5 mins

State class generation (hover, active, disabled) in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A@each loop
B@import directive
C@extend placeholder
D@function
In Sass, what does the selector &:hover mean inside a nested block?
ASelects the parent element when hovered
BSelects all hover elements
CSelects the child element on hover
DSelects the parent element with hover state
Which state class should visually indicate that an element cannot be interacted with?
A:hover
B:active
C:disabled
D:focus
What is the main benefit of using a Sass mixin for state classes?
AIt makes the CSS file larger
BIt reduces code repetition and keeps styles consistent
CIt disables the states automatically
DIt changes HTML structure
Which of these is NOT a common state class in CSS/Sass?
A:loading
B:active
C:disabled
D:hover
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.