Objective
To have a functioning "pinterest style" layout.
Background
I previously created a blog concept with Masonry and the layout was pretty smooth. To show how it is supposed to work, I posted This video on youtube
I had my original conceptual demo on codepen which used Foundation 5.
Then I forked this broken demo in question - on codepen.
But it does not work if I remove Foundation 5. But that is really weird because there are no foundation classes anywhere in the HTML.
Problem
This should not at all rely on Foundation 5. When I remove the external Foundation 5 file, the containers are floated to either side.
And the layout goes to single item per column even when the browser window accomodate many more.
Current State
It works but should not rely on Foundation.
Code
HTML
<div id="gallery-content" class="clearfix">
<!-- Case 1 -->
<div class="case-box item">
<img src="http://ships.bouwman.com/Planes/Boeing---X-48B.jpg" />
<div class="case-country country-us"></div>
<div class="case-description">
<p>Boeing Blended Wing X-48B</p>
</div>
<div class="case-options">
<a href="#">Details<i class="fa fa-arrows-alt"></i></a>
</div>
</div>
<!-- many more containers then closed off by #gallery-content div -->
CSS
The CSS from Foundation 5 coming from CDNJS.
//cdnjs.cloudflare.com/ajax/libs/foundation/5.1.1/css/foundation.min.css
And this code that I wrote
#gallery-content {
width: auto;
margin: 0 auto;
}
.item {
display: block;
float: left;
width: 300px;
margin: 0 20px 20px 0;
-webkit-transition: left .4s ease-in-out, top .4s ease-in-out .4s;
-moz-transition: left .4s ease-in-out, top .4s ease-in-out .4s;
-ms-transition: left .4s ease-in-out, top .4s ease-in-out .4s;
-o-transition: left .4s ease-in-out, top .4s ease-in-out .4s;
transition: left .4s ease-in-out, top .4s ease-in-out .4s;
}
.item img { width: 300px; height: auto; }
.case-box {
border: #888 1px solid;
padding-bottom: 72px;
position: relative;
}
.case-box {
-webkit-border-top-left-radius: 2px;
-webkit-border-top-right-radius: 2px;
-moz-border-radius-topleft: 2px;
-moz-border-radius-topright: 2px;
border-top-left-radius: 2px;
border-top-right-radius: 2px;
}
.clearfix:before, .clearfix:after { content: ""; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
JavaScript
jQuery
Masonry From CDNJS
//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.2/masonry.pkgd.min.js
And this code
$(document).ready(function() {
// Initialize Masonry
$('#gallery-content').masonry({
columnWidth: 320,
itemSelector: '.item',
isFitWidth: true,
isAnimated: !Modernizr.csstransitions
}).imagesLoaded(function() {
$(this).masonry('reload');
});
});
Live link:
http://codepen.io/JGallardo/pen/BuCbn.