同位素在div上间歇性返回0px高度 [英] Isotope intermittently returns 0px height on div

查看:80
本文介绍了同位素在div上间歇性返回0px高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的同位素布局在其容器上返回0px高度.刷新页面始终可以解决问题.

My Isotope layout is returning 0px height on its container. Refreshing the page always resolves the problem.

有人碰到这个吗?

这是我的同位素:

var $container = $('#Stream');
$container.imagesLoaded(function () {
    $container.isotope({
    itemSelector: '.stream-items',
    transformsEnabled: false
});

尽管在Chrome,Safari和FF上间歇性地发生,但持续发生. 断断续续"是指有时是在第一次加载时发生,其他是在第三次或第四次加载时发生,但最终总是会发生.

It occurs consistently albeit intermittently on Chrome, Safari, and FF. By "intermittently" I mean that sometimes it's on the first load, others on the third, or fourth, but eventually always happens.

我正在jQuery Mobile上运行,并尝试加载各种选项(window.load,pageinit等),但是无论如何都会发生.

I'm running on jQuery Mobile and have tried loading it the various options (window.load, pageinit, etc) but it happens regardless.

因此,任何想法都将受到赞赏,包括会强制进行刷新以始终解决问题的任何骇客行为.

So, any ideas are much appreciated including any hacks that will force a refresh which always fixes the problem.

谢谢!

更新:刚刚注意到,调整窗口大小也将重置为0px高度.

UPDATE: Just noticed that resizing the window resets to 0px height too.

推荐答案

同位素似乎没有足够的时间来计算图像. 所以我改用window.load.可以治疗:

It looks like Isotope doesn't have enough time to calc the images. So I use window.load instead. Works a treat:

$(window).load(function(){
    // Gallery Isotope
    $(function(){
        var $container = $('#gallery');
        $container.isotope({
        itemSelector: 'li',
            masonry : {
                columnWidth : 320
            }
        });
    });
});

这篇关于同位素在div上间歇性返回0px高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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