0
0
Tailwindmarkup~20 mins

Background size and position in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Background Size and Position Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What background size will make the image cover the entire element?
You have a div with a background image. Which Tailwind class makes the background image cover the entire div without stretching it out of proportion?
Tailwind
<div class="w-64 h-64 bg-[url('https://via.placeholder.com/150')] bg-no-repeat [CLASS_HERE] bg-center"></div>
Abg-contain
Bbg-fill
Cbg-auto
Dbg-cover
Attempts:
2 left
💡 Hint
Think about which class makes the image fill the element fully while keeping its aspect ratio.
selector
intermediate
1:30remaining
Which Tailwind class centers the background image?
You want the background image to be positioned exactly in the center of the element. Which Tailwind class should you use?
Tailwind
<div class="w-48 h-48 bg-[url('https://via.placeholder.com/100')] bg-no-repeat [CLASS_HERE] bg-cover"></div>
Abg-center
Bbg-top
Cbg-bottom
Dbg-left
Attempts:
2 left
💡 Hint
Think about the class name that suggests the middle position.
🧠 Conceptual
advanced
2:30remaining
What happens if you use both bg-cover and bg-center together?
Consider a div with classes 'bg-cover' and 'bg-center'. What is the combined effect on the background image?
Tailwind
<div class="w-64 h-64 bg-[url('https://via.placeholder.com/200')] bg-no-repeat bg-cover bg-center"></div>
AThe image is stretched to fill the div and aligned to the top-left corner.
BThe image covers the div and is centered, cropping edges if needed.
CThe image is shown at original size and positioned at bottom-right.
DThe image is tiled repeatedly across the div.
Attempts:
2 left
💡 Hint
Think about how 'cover' and 'center' work together for size and position.
📝 Syntax
advanced
1:30remaining
Which Tailwind class is invalid for background size?
Identify the invalid Tailwind class related to background size from the options below.
Abg-stretch
Bbg-auto
Cbg-contain
Dbg-cover
Attempts:
2 left
💡 Hint
Check if the class name matches official Tailwind background size utilities.
accessibility
expert
3:00remaining
How to ensure background images do not reduce accessibility?
Background images can sometimes cause accessibility issues. Which practice helps maintain accessibility when using background images in Tailwind?
AUse background images as the only way to convey important information.
BAlways add alt text attributes directly to background images.
CUse background images only for decorative purposes and provide meaningful text alternatives elsewhere.
DDisable keyboard navigation when background images are present.
Attempts:
2 left
💡 Hint
Think about how screen readers handle background images.