0
0
Tailwindmarkup~20 mins

Responsive card grid in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Responsive Grid Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
layout
intermediate
1:30remaining
Responsive grid columns with Tailwind CSS
Given this Tailwind CSS grid container, how many columns will be shown on a medium screen (min-width 768px)?
Tailwind
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4">
  <!-- cards here -->
</div>
A1 column
B2 columns
C3 columns
D4 columns
Attempts:
2 left
💡 Hint
Look at the class that starts with md: for medium screens.
selector
intermediate
1:00remaining
Tailwind CSS class for spacing between grid items
Which Tailwind CSS class adds consistent spacing between grid items in a card grid?
Agap-4
Bspace-x-4
Cp-4
Dm-4
Attempts:
2 left
💡 Hint
This class controls gaps between rows and columns in grids.
rendering
advanced
2:00remaining
Visual result of grid with fixed columns and gap
What will the user see when this Tailwind CSS code runs in a browser on a large screen?
Tailwind
<div class="grid grid-cols-3 gap-6 p-4">
  <div class="bg-blue-500 text-white p-6 rounded">Card 1</div>
  <div class="bg-blue-500 text-white p-6 rounded">Card 2</div>
  <div class="bg-blue-500 text-white p-6 rounded">Card 3</div>
  <div class="bg-blue-500 text-white p-6 rounded">Card 4</div>
</div>
AFour cards arranged in 2 columns with large spacing
BFour cards arranged in 4 columns with no spacing
CFour cards arranged in 3 columns with spacing between them
DFour cards stacked vertically with no spacing
Attempts:
2 left
💡 Hint
Check the grid-cols and gap classes for layout and spacing.
accessibility
advanced
2:00remaining
Improving accessibility in a responsive card grid
Which addition improves keyboard navigation and screen reader accessibility for a card grid?
Tailwind
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-5">
  <article class="bg-white p-4 rounded shadow">Card content</article>
  <article class="bg-white p-4 rounded shadow">Card content</article>
  <article class="bg-white p-4 rounded shadow">Card content</article>
</div>
AAdd aria-hidden="true" to all cards to hide them from screen readers
BAdd tabindex="0" to each <article> to make cards focusable
CAdd role="button" to the grid container <div>
DAdd alt="card image" to the <article> elements
Attempts:
2 left
💡 Hint
Think about how keyboard users can focus on cards.
🧠 Conceptual
expert
2:30remaining
Responsive behavior of grid with minmax and auto-fit
What is the effect of this Tailwind CSS custom grid class on different screen sizes?
...
AGrid creates as many columns as fit with minimum width 12rem, expanding to fill space
BGrid always has exactly 12 columns each 1fr wide
CGrid has fixed 1 column with width 12rem and no responsiveness
DGrid columns shrink below 12rem when screen is narrow
Attempts:
2 left
💡 Hint
Understand CSS grid repeat(auto-fit, minmax()) behavior.