I have a problem too layout elements in a box on my website…
I want to build a 900x900px size box and put items in there, and when I reach the height limit of 900, then it will be split into two columns
attached picture to explain.
.box {
width: 900px;
height: 900px;
}
.element {
width: 70px;
height: 70px;
}
<div class="box" id="">
<div class="element" id="">1</div>
<div class="element" id="">2</div>
<div class="element" id="">3</div>
<div class="element" id="">4</div>
<div class="element" id="">5</div>
<div class="element" id="">6</div>
<div class="element" id="">7</div>
<div class="element" id="">8</div>
......
</div>
I tried playing with flexbox and grid but I didn’t succeed.
2
Answers
you can use a combination of flexbox and CSS grid. Here’s your updated Code:
YOu can simply use a flexbox with a
flex-direction: column
. Then simply applyflex-wrap: wrap
to it to allow it breaking into a next column. If you want to start at the right side you can usedirection: RTL
on the container.