你可以检查JSFIDDLE
HTML
<div id="container">
<div class="item">
<img src="http://placekitten.com/150/130" />
</div>
<div class="item">
<img src="http://placekitten.com/160/120" />
</div>
<div class="item">
<img src="http://placekitten.com/170/110" />
</div>
<div class="item">
<img src="http://placekitten.com/180/100" />
</div>
<div class="item">
<img src="http://placekitten.com/190/110" />
</div>
<div class="item">
<img src="http://placekitten.com/180/120" />
</div>
<div class="item">
<img src="http://placekitten.com/170/130" />
</div>
<div class="item">
<img src="http://placekitten.com/160/140" />
</div>
<div class="item">
<img src="http://placekitten.com/150/130" />
</div>
</div>
JS
var container = document.querySelector('#container');
var msnry = new Masonry( container, {
columnWidth: 1,
itemSelector: '.item',
gutter: 10
});