I have a container with id parentContainer
and a bunch of divs (with width 44%, height depends on the div) inside this container, all with the class childDiv
. I want to display them sort of like this:
This is a two column gallery, and I could achieve this by creating two separate divs for the columns, and then putting the divs in there. However, I don't really want to do this, is there another way?
I'm trying to do this without the extra column divs, here is the CSS for the parent container:
#parentContainer {
width: 70vw;
height: 50vh;
border: 1px solid black;
position: absolute;
left: 50%;
top: 53%;
transform: translate(-50%, -50%);
padding: 50px;
display: block;
overflow-y: auto;
}
.childDiv {
float: left;
border: 1px solid black;
width: 44%;
margin: 1%;
}
<div id='parentContainer'>
<div class="childDiv" style="height: 200px;"></div>
<div class="childDiv" style="height: 160px;"></div>
<div class="childDiv" style="height: 200px;"></div>
<div class="childDiv" style="height: 200px;"></div>
</div>