I want to stack divs with different heights but same width within a div container.. from top to bottom going right.
Problem now is with divs that are short.. gives a ugly gap to the div above.
I've added a small sketch with what i want to do..
Thanks from norway!
The most common way to place two divs side by side is by using inline-block css property. The inline-block property on the parent placed the two divs side by side and as this is inline-block the text-align feature worked here just like an inline element does.
You can use Jquery's Equal Heights Plugin to accomplish, this plugins makes all the div of exact same height as other.
container div has two parent elements: the <body> and the <html> element. And we all know that the default value of the height property is auto , so if we also set the height of <body> and <html> elements to 100%, the resulting height of the container div becomes equal the 100% height of the browser window.
I suppose that you are using jQuery on your site. From the sketch I suggest to take a look at jQuery plugin called Masonry.
CSS:
.column { width:20em; float:left }
.column div { background:red; margin:1em }
HTML:
<div class="column">
<div></div>
<div></div>
<div></div>
</div>
<div class="column">
<div></div>
<div></div>
<div></div>
</div>
<div class="column">
<div></div>
<div></div>
<div></div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With