Quantcast
Channel: Active questions tagged flexbox - Stack Overflow
Viewing all articles
Browse latest Browse all 1675

CSS Grid/Flexbox Dynamic Displaying

$
0
0

I would like to display 8 elements in the page by the following rules. I am surprised that ChatGPT cannot give a proper solution after trying many times...

The rules are as simple as the following, using either CSS Grid system or Flexbox is ok.

When it is mobile mode, all items should be displayed in one single column.enter image description here

When it is desktop mode,The item 1, 2, 3, and 4 are in the first row, and item 5, 6, 7, and 8 are in the second row. The item 1 should occupy 50% of the first row, item 2, 3, and 4 should equally share the rest space of the first row. Item 5, 6, 7, and 8 always equally share the space of the second row.enter image description here

The item 3 displays dynamically. If the item 3 doesn't display, then item 2 should extends to take the item 3's space.

enter image description here

What to do that with CSS Grid system or Felxbox?

Which approach is much easier and simplified?


Viewing all articles
Browse latest Browse all 1675

Trending Articles



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