Ratio utilities help keep embedded content like videos or iframes at the right shape and size. This stops them from looking stretched or squished on different screens.
You want to add a YouTube video that looks good on phones and computers.
Embedding a Google Map that should keep its shape no matter the screen size.
Adding a responsive iframe for a presentation or slideshow.
Making sure a video player stays the same width-to-height ratio on all devices.
B. Missing the base class ratio on the wrapper div
C. The ratio class should be on the iframe, not the div
D. The src attribute value is invalid
Solution
Step 1: Check the required classes for ratio utility
Bootstrap requires the wrapper div to have the base class ratio along with the aspect ratio class like ratio-16x9.
Step 2: Verify the given code
The div only has ratio-16x9 but is missing the base ratio class, so the aspect ratio styling won't apply correctly.
Final Answer:
Missing the base class ratio on the wrapper div -> Option B
Quick Check:
Always include 'ratio' base class with ratio-size class [OK]
Hint: Always use both 'ratio' and ratio-size classes on wrapper div [OK]
Common Mistakes:
Using ratio class on iframe instead of div
Forgetting to add the base 'ratio' class
Assuming iframe needs ratio classes
5. You want to embed a video that should always appear as a perfect square on all devices, but also add a subtle shadow around it. Which Bootstrap classes and structure should you use?
hard
A. <div class='ratio ratio-1x1 shadow-sm'><iframe src='video.mp4' title='Video'></iframe></div>
B. <iframe class='ratio-1x1 shadow-sm' src='video.mp4' title='Video'></iframe>
C. <div class='ratio-16x9 shadow-sm'><iframe src='video.mp4' title='Video'></iframe></div>
D. <div class='shadow-sm'><iframe class='ratio ratio-1x1' src='video.mp4' title='Video'></iframe></div>
Solution
Step 1: Choose the correct ratio class for a square
The class ratio-1x1 ensures the embed is a perfect square on all devices.
Step 2: Add shadow styling correctly
The shadow utility shadow-sm should be added to the same wrapper div that holds the ratio classes to apply the shadow around the embed.
Step 3: Confirm correct HTML structure
The iframe should be inside the div with both ratio and shadow-sm classes. Applying ratio classes directly on iframe is incorrect.
Final Answer:
<div class='ratio ratio-1x1 shadow-sm'><iframe src='video.mp4' title='Video'></iframe></div> -> Option A
Quick Check:
Wrapper div with ratio and shadow classes = correct [OK]
Hint: Add shadow class to ratio wrapper div for styling [OK]
Common Mistakes:
Putting ratio classes on iframe instead of div
Using wrong ratio class for square shape
Adding shadow to iframe instead of wrapper
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.