I was try to make like the example one for tablet layout, here’s my code :
<div class="grid grid-cols-2 gap-8 justify-items-center px-8 mt-8 md:grid-cols-3 lg:grid-cols-4">
<div class="w-28 aspect-video bg-green-500"></div>
<div class="w-28 aspect-video bg-green-500"></div>
<div class="w-28 aspect-video bg-green-500"></div>
<div class="w-28 aspect-video bg-green-500"></div>
<div class="w-28 aspect-video bg-green-500"></div>
<div class="w-28 aspect-video bg-green-500"></div>
<div class="w-28 aspect-video bg-green-500"></div>
<div class="w-28 aspect-video bg-green-500"></div>
</div>
So, there’s any alternative for that?
2
Answers
You could consider doubling the grid column track count, and then offseting the items by one column:
I think you should use flex for that instead of grid and setting the max-with to the padding + gap + columns width, like:
https://play.tailwindcss.com/4Sexse1HX4