How can I implement a grid system in my divs using CSS Grid?
P粉195200437
P粉195200437 2023-09-08 16:03:49
0
2
470

I want to create a div with 2 columns, when I add an item in the parent div it should be in the first column, when the first column has 3 elements and I want to add other items it should Located in the second column. This is the image I'm looking for:

I found no response on the internet, I tried the css grid generator but without any results..

CSS Grid Generator but I can't get the right answer

P粉195200437
P粉195200437

reply all(2)
P粉427877676

Ok...it looks like you just have a problem with mesh flow. To change it, use grid-auto-flow:column; That's it, the grid's flow will change from rows to columns. You can change grid-template-rows as needed.

P粉469090753

What you need to do in html is:

<div class="parent">
   <div class="child">1</div>
   <div class="child">2</div>
   <div class="child">3</div>
   <div class="child">4</div>
   <div class="child">5</div>
   <div class="child">6</div>
</div>

and CSS:

.parent{
     display:grid;
     grid-template-columns: 1fr 1fr;
     grid-auto-flow: column;
     grid-template-rows:1fr 1fr 1fr;
 }

Demo

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template