尝试like Beyonce's website但使用Isotope代替Masonry。
任何想法为什么默认情况下这不会起作用,但只有在调整窗口大小后呢?
var $container = $("ul");
$container.imagesLoaded(function() {
$container.isotope({
itemSelector: "li",
animationEngine: "jquery",
sortBy: "random",
// http://isotope.metafizzy.co/demos/fluid-responsive.html
resizable: false,
masonry: { columnWidth: $container.width() / 3 }
});
});
$(window).smartresize(function() {
$container.isotope({
masonry: { columnWidth: $container.width() / 3 }
});
});
答案 0 :(得分:2)
var $container = $("ul");
var size = function () {
console.log('wee!');
$container.isotope({
masonry: {
columnWidth: $container.width() / 3
}
});
}
$container.imagesLoaded(function () {
$container.isotope({
itemSelector: "li",
animationEngine: "jquery",
sortBy: "random",
resizable: false,
masonry: {
columnWidth: $container.width() / 3
}
});
size();
});
$(window).smartresize(size);
// $(size); // this is an issue, because the images haven't yet loaded!