Recently, I started making an admin page on my site to edit multiple small tables (1-5 entries). They got all displayed on one page, and the tables got nested in a div as fo
You can solve this in various ways, depending on what you want to use and needed browser support.
.container {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
and then doing the same on the children, or elements of the grid, you can make it so they all stretch to fill in that ugly white space, thus achieving another grid layout without being... unelegant?
<div class="row">
<div class="col-sm-4">
<!-- table 1 -->
<!-- table 2 -->
</div>
<div class="col-sm-4">
<!-- table 3 -->
<!-- table 4 -->
</div>
<div class="col-sm-4">
<!-- table 5 -->
<!-- table 6 -->
</div>
</div>
It might not be an optimal solution in case your tables need to be in a precise order, as well.
This is due to varying column height. You need a "clearfix" reset every 3 columns to force even wrapping. One way is to use the approach recommended by Bootstrap, or in this specific case you can use a simple CSS clearfix like this..
@media (min-width:992px) {
.auto-clear .col-md-4:nth-child(3n+1){clear:left;}
}
Demo: http://codeply.com/go/mONLiFj30T
For other "clearfix" scenarios with different col width and grid tiers, there is a universal CSS only clearfix solution which will fit more scenarios (unsupported).
Another solution would be CSS columns, for a "masonry" style layout, but it doesn't use the Bootstrap grid: http://www.bootply.com/mYkzRDvbEq
See my more complete answer on this issue
All the columns in one container > row?
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-4">
<!--table 1-->
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<!--table 2-->
</div>
...
<div class="col-xs-12 col-sm-4 col-md-4">
<!--table 6-->
</div
</div>
You could use
<div class="clearfix visible-xs-block"></div>
For the various sizes at certain positions while keeping it flexible for different layouts.
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-4">
<!--table 1-->
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<!--table 2-->
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<!--table 3-->
</div>
<div class="clearfix visible-sm-block visible-md-block"></div>
...
</div>