Challenge - 5 Problems
Bootstrap Ratio Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
Understanding Bootstrap Ratio Utility Classes
Which Bootstrap class should you add to a
<div> to create a responsive 16:9 aspect ratio container for embedded content?Bootsrap
<div class="ratio"> <iframe src="https://www.example.com" title="Example"></iframe> </div>
Attempts:
2 left
💡 Hint
Bootstrap 5 uses the
ratio-* classes for aspect ratios.✗ Incorrect
Bootstrap 5 introduced the
ratio utility with classes like ratio-16x9 to create responsive containers with fixed aspect ratios. The older embed-responsive-* classes were from Bootstrap 4 and are not valid in Bootstrap 5.❓ selector
intermediate1:30remaining
CSS Selector for Ratio Utility
Given the following CSS snippet from Bootstrap's ratio utility, which selector targets all elements with a 1:1 aspect ratio?
Bootsrap
.ratio-1x1 {
aspect-ratio: 1 / 1;
}Attempts:
2 left
💡 Hint
Look for the class that specifically sets aspect-ratio to 1 / 1.
✗ Incorrect
The class
ratio-1x1 specifically sets the aspect ratio to 1:1. Other classes like ratio-16x9 set different ratios. The attribute selector [class^="ratio-"] matches all ratio classes, not just 1:1.🧠 Conceptual
advanced1:30remaining
Why Use Ratio Utilities for Embeds?
What is the main benefit of using Bootstrap's ratio utilities for embedded content like videos or iframes?
Attempts:
2 left
💡 Hint
Think about how aspect ratio affects the size and shape of embedded content on different devices.
✗ Incorrect
Bootstrap's ratio utilities keep the width and height of embedded content proportional, so videos or iframes resize nicely on all devices without distortion or overflow.
❓ layout
advanced2:00remaining
Combining Ratio Utility with Flexbox
You want to center a video embed with a 4:3 aspect ratio horizontally and vertically inside a container using Bootstrap. Which combination of classes achieves this?
Attempts:
2 left
💡 Hint
Flexbox classes
d-flex, justify-content-center, and align-items-center help center content.✗ Incorrect
Using
d-flex justify-content-center align-items-center centers the embed horizontally and vertically. The ratio ratio-4x3 class sets the correct aspect ratio for the embed container.❓ accessibility
expert2:30remaining
Accessibility Considerations for Ratio Utility Embeds
When embedding a video using Bootstrap's ratio utilities, which practice improves accessibility the most?
Attempts:
2 left
💡 Hint
Think about how screen readers understand embedded content.
✗ Incorrect
Providing a descriptive
title attribute on the iframe helps screen reader users understand what the embedded content is about. Hiding or removing keyboard focus can make content inaccessible.