0
0
SASSmarkup~20 mins

RGBA and opacity manipulation in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
RGBA and Opacity Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2: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;
}
Abackground-color: rgba(255, 0, 0, 0.3);
Bbackground-color: rgba(255, 0, 0, 0.5);
Cbackground-color: rgba(255, 0, 0, 0.8);
Dbackground-color: rgba(255, 0, 0, 0.15);
Attempts:
2 left
💡 Hint
Multiply the alpha value of the base color by the overlay opacity.
🧠 Conceptual
intermediate
1: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?
Argba($color, 0.7)
Bopacity($color, 0.7)
Cchange-opacity($color, 0.7)
Dset-alpha($color, 0.7)
Attempts:
2 left
💡 Hint
Sass's rgba() can take a color and a new alpha value.
selector
advanced
2: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
}
A.container { background-color: $overlay-color; }
B.container::before { content: ""; position: absolute; inset: 0; background-color: $overlay-color; }
C.container::after { content: ""; position: relative; background-color: $overlay-color; }
D.container::before { content: ""; position: fixed; inset: 0; background-color: $overlay-color; }
Attempts:
2 left
💡 Hint
Use a pseudo-element with absolute positioning to overlay inside the container.
layout
advanced
3: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
}
A
.container { background-color: $bg-color; }
.container p { color: black; }
B
.container { background-color: $bg-color; opacity: 0.5; }
.container p { color: black; }
C
.container { position: relative; }
.container::before { content: ""; position: absolute; inset: 0; background-color: $bg-color; z-index: 0; }
.container p { position: relative; z-index: 1; }
D
.container { background-color: blue; opacity: 0.5; }
.container p { opacity: 1; }
Attempts:
2 left
💡 Hint
Use a separate overlay layer so text opacity is not affected.
accessibility
expert
3: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?
A0.45
B0.75
C0.18
D0.90
Attempts:
2 left
💡 Hint
WCAG AA requires 4.5:1 contrast ratio for normal text.