I'm not huge fan of bootstrap, so I was wondering if it is possible without it.
I have 6 divs which I want to order in 2 rows and 3 cols. I want the space between each row/col to be exact. I can do this by calculation but was wondering if there is smarter way around.
Note that .item height 50px is just for the example and is not set in the original code but it takes the height it needs to fit the content.
Also If I remove the .container height it will mess the horizontal blue line. I really do not want to rely on .container height.
I think it will be pretty easy with some JS which sets the height but I'd rather skip that and just use .container height instead. Thanks!
.container {
display: flex;
justify-content: space-between;
align-content: space-between;
width: 500px;
height: 125px;
background: blue;
flex-wrap: wrap;
}
.item {
background: red;
width: 30%;
height: 50px;
}
<div class='container'>
<div class='item'> item1 </div>
<div class='item'> item2 </div>
<div class='item'> item3 </div>
<div class='item'> item4 </div>
<div class='item'> item5 </div>
<div class='item'> item6 </div>
</div>
EDIT: Since I can see there is no way without JS I'll just use the .container's height. If somebody prefers the JS - here is a JQuery solution
$('.container').height(
$('.item').height()*2 +
(($('.container').width() - 3*$('.item').width()) /2)
);
Thanks for the answers!