Challenge - 5 Problems
RGBA and Opacity Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the output color of this Sass code?
Given the Sass code below, what is the resulting background color in CSS?
SASS
$base-color: rgba(255, 0, 0, 0.5); $overlay-opacity: 0.3; $final-color: rgba(red($base-color), green($base-color), blue($base-color), alpha($base-color) * $overlay-opacity); .element { background-color: $final-color; }
Attempts:
2 left
💡 Hint
Multiply the alpha value of the base color by the overlay opacity.
✗ Incorrect
The base color has alpha 0.5. Multiplying by 0.3 gives 0.15, so the final rgba alpha is 0.15.
🧠 Conceptual
intermediate1:30remaining
Which Sass function correctly changes opacity without altering color channels?
You want to keep the red, green, and blue values the same but change only the opacity of a color variable $color to 0.7. Which function call achieves this?
Attempts:
2 left
💡 Hint
Sass's rgba() can take a color and a new alpha value.
✗ Incorrect
The rgba() function in Sass can take a color and a new alpha value to change opacity without changing RGB.
❓ selector
advanced2:30remaining
Which selector applies a semi-transparent overlay using Sass variables?
Given these Sass variables, which selector rule correctly applies a semi-transparent black overlay with 40% opacity over a container?
SASS
$overlay-color: rgba(0, 0, 0, 0.4); .container { // your code here }
Attempts:
2 left
💡 Hint
Use a pseudo-element with absolute positioning to overlay inside the container.
✗ Incorrect
Option B uses ::before with absolute positioning and inset 0 to cover the container with the overlay color.
❓ layout
advanced3:00remaining
How to keep text fully opaque over a semi-transparent background in Sass?
You want a container with a semi-transparent blue background but the text inside should be fully opaque. Which Sass and CSS approach achieves this?
SASS
$bg-color: rgba(0, 0, 255, 0.5); .container { background-color: $bg-color; // your code here } .container p { // your code here }
Attempts:
2 left
💡 Hint
Use a separate overlay layer so text opacity is not affected.
✗ Incorrect
Setting opacity on container affects all children. Using a ::before overlay with z-index keeps text fully opaque.
❓ accessibility
expert3:00remaining
What is the minimum opacity for text background to maintain WCAG AA contrast?
You have white text (#FFFFFF) on a black background (#000000). You want to add a semi-transparent black overlay behind the text using rgba(0,0,0,alpha). What is the minimum alpha value to keep at least 4.5:1 contrast ratio for WCAG AA compliance?
Attempts:
2 left
💡 Hint
WCAG AA requires 4.5:1 contrast ratio for normal text.
✗ Incorrect
A black overlay with alpha 0.45 on white text maintains the minimum 4.5:1 contrast ratio over black background.