【发布时间】:2015-08-19 07:11:14
【问题描述】:
绝对把我的头发拉到这个上。 GitHub 似乎没有提供黑白解决方案 - 这很奇怪,因为它似乎是一个相当简单的概念。也许我只是不明白。
基本上,我正在尝试创建一个 fluid 和 responsive 投资组合 - 使用 Isotope 过滤项目。过滤效果很好,4 列完全流畅,调整窗口大小时一切看起来都很棒。
但是,对于移动设备和平板电脑布局,我只需要将 4 列 布局调整为 2 列 布局。
我试过了:
$(window).load(function(){
var $container = $('#thumbs');
$container.isotope({
filter: '*',
animationOptions: {
duration: 750,
easing: 'linear',
queue: false,
},
});
// initialize Isotope
$container.isotope({
// options...
resizable: false, // disable normal resizing
// set columnWidth to a percentage of container width
masonry: { columnWidth: $container.width() / 4 },
});
// update columnWidth on window resize
$(window).smartresize(function(){
$container.isotope({
// update columnWidth to a percentage of container width
masonry: { columnWidth: $container.width() / 4 }
});
});
// My attempt at using media queries to change 'columnWidth'
$(window).resize(function() {
var width = $(window).width();
if (width < 768) {
$container.isotope( {
// update columnWidth to half of container width
masonry: { columnWidth: $container.width() / 2 }
});
}
});
});
没用:(
任何帮助将不胜感激。
【问题讨论】:
标签: responsive-design media-queries jquery-isotope fluid