My goal is to design a 3-column grid using Twitter Bootstrap and Isotope. However, when I resize the browser to force the layout into a single column mode, Isotope fails and leaves large spaces both vertically and horizontally.
Regular Layout
Issues in Single Column
As shown in the image above, there are significant vertical gaps, and the first cell fails to expand to 100% width.
Here's the link to my Codepen.
HTML:
<html lang="en" class="">
<head>
<meta charset="utf-8" />
<title>isotope</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<div class="masonry row">
<div class="item col-lg-4 col-md-6">
<div class="cell">
<h3>
<a href="#">1. One</a>
</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam auctor metus et porta facilisis. </p>
<p>Aenean congue lorem accumsan erat tempor, eu tempus ex tristique.</p>
<small class="text-muted">27 Nov 2014</small>
<div class="pull-right">
<a class="btn btn-primary btn-xs" href="#">auctor</a>
</div>
</div>
</div>
<!-- more items -->
</div>
</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.1.1/isotope.pkgd.min.js"></script>
</body>
</html>
CSS:
.masonry {
padding: 0;
margin-left: -15px;
margin-right: -15px;
}
.item {
margin-right: -1px;
margin-bottom: 20px;
padding: 0 10px;
}
.cell {
padding: 15px;
background-color: #FFFFFF;
box-shadow: 0 10px 6px -6px #777;
border: 1px solid #F6F6F6;
}
JavaScript:
var isotope = new Isotope('.masonry', {
itemSelector: '.item',
layoutMode: 'masonry',
masonry: {
columnWidth: '.item'
}
});
isotope.layout();
Upon reloading the browser in a narrow viewport, the vertical gaps become uniform, but the first cell still lacks 100% width expansion.
Any assistance would be greatly appreciated.