I'm attempting to create a layout using Bootstrap 3.2.0 with tiled divs in a single row for screens wider than 768px. The divs have heights of either 50px or 100px, controlled by the classes "home-height-single" and "home-height-double," and widths adjusted by the class "col-sm-x":
Below is my current markup and CSS:
CSS
.red{ background-color: red; }
.blue{ background-color: blue; }
.green{ background-color: green; }
.yellow{ background-color: yellow; }
.purple{ background-color: purple; }
.home-height-single{ min-height: 50px; }
.home-height-double{ min-height: 100px; }
@media (min-width: 768px) {
.b-col {
float: right;
}
}
Markup:
<div class="row">
<div class="col-sm-6 home-height-double green">
<p>1</p>
</div>
<div class="col-sm-4 home-height-single blue b-col">
<p>3</p>
</div>
<div class="col-sm-2 home-height-single purple b-col">
<p>2</p>
</div>
<div class="col-sm-2 home-height-single green b-col">
<p>7</p>
</div>
<div class="col-sm-4 home-height-double yellow b-col">
<p>6</p>
</div>
<div class="col-sm-2 home-height-single blue">
<p>4</p>
</div>
<div class="col-sm-4 home-height-single red">
<p>5</p>
</div>
<div class="col-sm-2 home-height-single red b-col">
<p>8</p>
</div>
</div>
The current result is displayed below, where div 8 is not filling the gap:
JSFiddle - Showing the issue
I am aware that I could use 2 columns and wrap the divs in 2 parent divs, but I prefer to avoid this. This is because, for mobile view, I intend to position divs 2 and 4 side by side rather than stacked, which may not be achievable if the divs are wrapped in 2 columns.
For instance, my mobile layout is planned to resemble this once the current issue is resolved: