砌体重叠问题 [英] Masonry overlapping issue

查看:100
本文介绍了砌体重叠问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的博客文章中使用David DeSandro的Masonry,我有一个容器重叠的烦人问题。一旦我重新调整浏览器窗口的大小,一切正常:

I am trying to use David DeSandro's Masonry on my blog posts and I have an anoying issue where the containers overlap. As soon as I re-size my browser window, everything works fine:

<!--The code I placed in my template head section:-->
<script src='http://desandro.github.io/imagesloaded/imagesloaded.pkgd.min.js'/>
<script src='http://masonry.desandro.com/masonry.pkgd.min.js'/>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js' type='text/javascript'/>
<b:if cond='data:blog.pageType != &quot;index&quot;'>
<script>
$(document).ready(function(){
    var $container = $(&#39;AJcontainer&#39;);
        $container.imagesLoaded( function() {
        $container.masonry({
            itemSelector: &#39;AJpost&#39;,
            });
    });
    });
</script>
</b:if>



<!--The code in my posts:-->
<div class="js-masonry" id="AJpost">
<div class="AJcontainer"><a href="*.jpg">
<img src="*.jpg" />
<div class="AJsumm">(...)</div></a>
</div>

我在过去几天搜索了一个解决方案但没有成功:
imagesLoaded 似乎不起作用,(窗口).load 而不是(文档).ready 无法正常工作

I have searched for a solution in the past few days with no success: imagesLoaded does not seem to work, (window).load instead of (document).ready is not working either

这是正在进行中的工作网站:
http://infinitywashere.blogspot.co.uk/2014/04/sketches-again.html

This is the work in progress website: http://infinitywashere.blogspot.co.uk/2014/04/sketches-again.html

非常感谢任何帮助!

推荐答案

可能是JQuery语法问题,试试这个:

Maybe problem with the JQuery syntax, try this:

$(window).load(function(){
    var $container = $('#AJpost');
    $container.imagesLoaded( function() {
        $container.masonry({
            itemSelector: '.AJcontainer'
        });
    });
});

尝试不使用imagesLoaded:

Have a try without imagesLoaded:

$(window).load(function() {  
    var $container = $('#AJpost');
    $container.masonry({
        itemSelector: '.AJcontainer'
    });
}); 

这篇关于砌体重叠问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆