I have divs inside a a larger parent div. All these child divs have a 50% width. The idea is to have 2 columns. Also these child divs have a dynamic height.
I have an example here. https://jsfiddle.net/y2jpr052/
This is done with inline-block. And as you can see, there is bizarre spacing between the divs. What is that exactly? And how can I get rid of it. Thanks!
UPDATE: I see that the divs are all aligned on the top per row, hence the weird spacing. That's what I want to get rid of.
Another update: Basically no vertical spacing. Or spacing depending on the margin/padding of the children div. Each colored box here being a floated div with dynamic height.
#index.html
<div id="modules">
<div id="m1" class="module">m1</div>
<div id="m2" class="module">m2</div>
<div id="m3" class="module">m3</div>
<div id="m4" class="module">m4</div>
<div id="m5" class="module">m5</div>
<div id="m6" class="module">m6</div>
<div id="m7" class="module">m7</div>
<div id="m8" class="module">m8</div>
<div id="m9" class="module">m9</div>
<div id="m10" class="module">m10</div>
</div>
#index.css
#modules {
width: 100%;
border: 1px solid red;
overflow: auto;
}
.module {
display: inline-block;
width: 45%;
height: 50px;
border: 1px solid black;
}
#m1 {
height: 70px;
}
#m2 {
height: 40px;
}
#m3 {
height: 100px;
}
#m4 {
height: 100px;
}
#m5 {
height: 85px;
}
#m6 {
height: 70px;
}
#m7 {
height: 55px;
}
#m8 {
height: 77px;
}
#m9 {
height: 100px;
}
Set the font-size for parent DIV of the DIVs to 0 shall solve this problem.
Fiddle here: https://jsfiddle.net/Math3w_C/y2jpr052/1/
What you want here is two columns.
So you just need to add this css:
See this jsfiddle: https://jsfiddle.net/y2jpr052/10/