Reputation: 406
I've been working on an application that dynamicaly adds elements to the DOM. The added elements are of two types: ones with height 50px and ones with 100px. They are displayed in with the help of the bootstrap grid system.
Working example:
<div>
<div class="col-xs-6" style="height: 100px;">1</div>
<div class="col-xs-6" style="height: 50px;">2</div>
<div class="col-xs-6" style="height: 50px;">3</div>
</div>
But when i try to rearrange, some unexpected spaces occur on certain layouts:
<div>
<div class="col-xs-6" style="height: 50px;">2</div>
<div class="col-xs-6" style="height: 100px;">1</div>
<div class="col-xs-6" style="height: 50px;">3</div>
</div>
Between element '1' and '3' there is a 50px wide gap. Is there any arrangement where the element '3' is placed in that gap? Why is this gap occuring?
Upvotes: 1
Views: 689
Reputation: 11496
This is happening because you have added inline style for height.
style="height: 100px;
style="height: 50px;
style="height: 50px;
To know it better look the example here jsfiddle 1 jsfiddle 2
Upvotes: 1
Reputation: 362400
@Gaurav is correct.. it's happening because you have specific height
set. When the height:100px
col is placed 2nd it forces #3 to wrap to a new row since the Bootstrap colums float left, but do not float right.
A workaround would be to use the pull-right
class on the taller (100px) column...
Upvotes: 0