Challenge - 5 Problems
Card Overlay Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
Identify the overlay text color in this Bootstrap card
Given this Bootstrap card with an image overlay, what color will the overlay text appear as in the browser?
Bootsrap
<div class="card bg-dark text-white"> <img src="https://via.placeholder.com/300x180" class="card-img" alt="Sample Image"> <div class="card-img-overlay"> <h5 class="card-title">Overlay Title</h5> <p class="card-text">Overlay text content.</p> </div> </div>
Attempts:
2 left
💡 Hint
Look at the text color classes applied to the card container.
✗ Incorrect
The card has the class 'text-white' which sets the text color inside the card to white, including the overlay text.
❓ selector
intermediate2:00remaining
Which CSS selector targets the overlay text inside a Bootstrap card?
You want to style the overlay text inside a Bootstrap card image overlay. Which CSS selector correctly targets the overlay text elements?
Attempts:
2 left
💡 Hint
The overlay text is inside the element with class 'card-img-overlay'.
✗ Incorrect
The overlay text elements like titles and paragraphs are inside the '.card-img-overlay' container, so selecting '.card-img-overlay .card-title' and '.card-img-overlay .card-text' targets them correctly.
🧠 Conceptual
advanced2:00remaining
Why use 'position-relative' on the card container with image overlays?
In Bootstrap, when adding an image overlay inside a card, why is it important to have the card container use the class 'position-relative'?
Attempts:
2 left
💡 Hint
Think about how absolute positioning works in CSS.
✗ Incorrect
Absolute positioning places elements relative to the nearest positioned ancestor. 'position-relative' on the card container ensures the overlay is positioned inside the card boundaries.
❓ layout
advanced2:00remaining
How to make a Bootstrap card image overlay text vertically centered?
You want the overlay text inside a Bootstrap card image overlay to be vertically centered over the image. Which approach achieves this best?
Bootsrap
<div class="card bg-dark text-white position-relative"> <img src="https://via.placeholder.com/300x180" class="card-img" alt="Sample Image"> <div class="card-img-overlay d-flex justify-content-center align-items-center"> <h5 class="card-title">Centered Title</h5> </div> </div>
Attempts:
2 left
💡 Hint
Flexbox utilities in Bootstrap help with centering.
✗ Incorrect
'd-flex' makes the overlay a flex container. 'justify-content-center' centers horizontally, and 'align-items-center' centers vertically.
❓ accessibility
expert3:00remaining
Best practice for accessible image overlays in Bootstrap cards
For a Bootstrap card with an image and text overlay, which practice improves accessibility the most for screen reader users?
Bootsrap
<div class="card bg-dark text-white position-relative"> <img src="https://via.placeholder.com/300x180" class="card-img" alt="Sunset over mountains"> <div class="card-img-overlay"> <h5 class="card-title">Mountain Sunset</h5> <p class="card-text">A beautiful view of the sun setting behind the peaks.</p> </div> </div>
Attempts:
2 left
💡 Hint
Think about how screen readers read images and text overlays.
✗ Incorrect
A meaningful alt attribute describes the image content for screen readers. The overlay text complements the image but does not replace the alt text.