我正在使用 masonry jquery 插件在容器中排列一些图像,该插件似乎正在工作,但它没有正确显示这些项目。有些空格可以由项目填充,但项目“浮动”留在下一行,这不应该发生。
这个问题可以在这里看到: http ://riley87.co.uk/theme/ionic/portfolio-masonry.html
这是代码:
<ul class="col full-width masonry-wrap filter-wrap">
<li class="item web" style="width: 49.9099099099%;">
<a href="img/portfolio/554x520-1.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/554x520-1.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 49.9099099099%;">
<a href="img/portfolio/554x259-1.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/554x259-1.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 24.8648648649%;">
<a href="img/portfolio/276x259-1.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/276x259-1.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 24.8648648649%;">
<a href="img/portfolio/276x520-1.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/276x520-1.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 24.8648648649%;">
<a href="img/portfolio/276x259-2.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/276x259-2.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 49.9099099099%;">
<a href="img/portfolio/554x259-2.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/554x259-2.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 49.9099099099%;">
<a href="img/portfolio/554x259-3.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/554x259-3.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 49.9099099099%;">
<a href="img/portfolio/554x520-2.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/554x520-2.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 24.8648648649%;">
<a href="img/portfolio/276x520-2.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/276x520-2.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 24.8648648649%;">
<a href="img/portfolio/276x259-3.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/276x259-3.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 49.9099099099%;">
<a href="img/portfolio/554x259-4.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/554x259-4.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
<li class="item web" style="width: 24.8648648649%;">
<a href="img/portfolio/276x259-4.jpg" class="img-wrap view" rel="photography">
<img src="img/portfolio/276x259-4.jpg" alt="">
<div class="img-overlay">
<div class="icon-only"><i class="fa fa-eye"></i></div>
</div>
</a>
</li>
</ul>
<script>
$(document).ready(function(){
var container = document.querySelector('.masonry-wrap');
var msnry = new Masonry( container, {
// options
itemSelector: '.item'
});
var msnry;
// initialize Masonry after all images have loaded
imagesLoaded( container, function() {
msnry = new Masonry( container );
});
});
</script>