1

我在我的站点中使用jQuery Masonry来显示博客文章。并且每个帖子块都添加了Facebook评论框。当有新的评论时,容器div扩展,不幸的是与下面的一个重叠。在这种情况下,我需要重新运行砌体脚本来重新加载块。 Screenshot如何检查div的高度来重新排列div块

所以我使用Ben Alman's Jquery Resize Event Plugin检查在div的高度变化,这样的砌体脚本根据新的大小重新定位块,避免重叠。

虽然它不工作,并且当我用萤火虫检查它时似乎没有错误。我是Jquery的新手,我希望我只是在这里犯了一个简单的错误。

如果你想看看它,请检查bjk-tribun.com 当你在评论框中输入一些评论时,你会看到重叠。

$(function(){ 
    // Bind the resize event. When any test element's size changes, update its 
    // corresponding info div. 
    var iframe = $(".fb_iframe_widget"); 

    // Called once the Iframe's content is loaded. 
    iframe.load(function(){ 
    // The Iframe's child page BODY element. 
    var iframe_content = iframe.contents().find('body'); 

    // Bind the resize event. When the iframe's size changes, update its height as 
    // well as the corresponding info div. 
    iframe_content.resize(function(){ 
     var elem = $(this); 

     // Resize the IFrame. 
     iframe.css({ height: elem.outerHeight(true) }); 

     $('#sort').masonry(reloadItems); 

    // Resize the Iframe and update the info div immediately. 
    iframe_content.resize(); 
    }); 
}); 

回答

0

根据您使用的jQuery的版本,你可能需要在你的CSS属性添加的PX装置:

iframe.css({ height: elem.outerHeight(true) + "px" }); 
0

好吧,我不知道为什么,但我一旦打开颜色框的。 js这是一个灯箱插件Jquery Masonry插件开始对div的大小作出反应。因此,如果有人遇到同样的问题,他们应该首先尝试禁用其他jquery插件,以避免花费整整一周的时间。

我还禁用了本人插入的Ben Alman插件。砌体足以应付调整大小事件。