Quantcast
Viewing all articles
Browse latest Browse all 1326

How can I change col/row behavior based on available space? [closed]

I have a set of cards, whose have their own cards, like this (i am using TailwindCSS btw):

<script src="https://cdn.tailwindcss.com"></script><div class="grid grid-cols-3 gap-4"><div class="flex flex-wrap justify-between gap-4 border"><div class="flex-grow">Content 1</div><div class="flex-grow">Content 2</div><div class="flex-grow">Content 3</div></div><div class="flex flex-wrap justify-between gap-4 border"><div class="flex-grow">Content 4</div><div class="flex-grow">Content 5</div></div></div>

The end result will be something like this, which is fine:a image showing the rendered result of the cards

But depending on screen size, i can get a result like this:

a image showing the rendered result of the cards with a gap on the second card

So, what i want to do is that, when there is room available, the "mini cards" act like rows instead of columns, like this (but dynamic):

a image showing the rendered result of the cards without a gap on the second card

<script src="https://cdn.tailwindcss.com"></script><div class="grid grid-cols-3 gap-4"><div class="flex flex-wrap justify-between gap-4 border"><div class="flex-grow">Content 1</div><div class="flex-grow">Content 2</div><div class="flex-grow">Content 3</div></div><div class="flex flex-wrap flex-col justify-between gap-4 border"><div class="flex-grow">Content 4</div><div class="flex-grow">Content 5</div></div></div>

Is there a way to achieve this with CSS?


Viewing all articles
Browse latest Browse all 1326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>