0
0
Bootsrapmarkup~20 mins

Card images and overlays in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Card Overlay Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2: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>
ABlack
BGray
CWhite
DBlue
Attempts:
2 left
💡 Hint
Look at the text color classes applied to the card container.
selector
intermediate
2: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?
A.card .card-img .card-title
B.card-title .card-img-overlay
C.card-img .card-img-overlay .card-text
D.card-img-overlay .card-title, .card-img-overlay .card-text
Attempts:
2 left
💡 Hint
The overlay text is inside the element with class 'card-img-overlay'.
🧠 Conceptual
advanced
2: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'?
AIt makes the card background transparent for the overlay to show.
BIt sets the card as a reference point so the overlay can be positioned absolutely inside it.
CIt changes the card's display to flex for better layout.
DIt automatically adds padding around the overlay text.
Attempts:
2 left
💡 Hint
Think about how absolute positioning works in CSS.
layout
advanced
2: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>
AAdd 'd-flex justify-content-center align-items-center' to '.card-img-overlay' to center content vertically and horizontally.
BAdd 'text-center' to '.card-img-overlay' only.
CAdd 'mt-auto mb-auto' classes to the overlay text element.
DWrap the overlay text in a <center> tag.
Attempts:
2 left
💡 Hint
Flexbox utilities in Bootstrap help with centering.
accessibility
expert
3: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>
AProvide a meaningful alt attribute on the image describing the scene.
BUse aria-hidden="true" on the overlay text to avoid redundancy.
CRemove the alt attribute from the image to avoid confusion.
DAdd role="presentation" to the image to make it decorative.
Attempts:
2 left
💡 Hint
Think about how screen readers read images and text overlays.