Javascript jQuery同位素包装器:是否可以将所有同位素项目调整为相同高度(每行)?
我有一个网站使用jquery的同位素包装器,html代码如下:Javascript jQuery同位素包装器:是否可以将所有同位素项目调整为相同高度(每行)?,javascript,jquery,jquery-isotope,jquery-masonry,masonry,Javascript,Jquery,Jquery Isotope,Jquery Masonry,Masonry,我有一个网站使用jquery的同位素包装器,html代码如下: <div class="isotopeWrapper clearfix isotope"> <article class="col-sm-4 isotopeItem isotope-item"> <!-- item1 ---> </article> <article class="col-sm-4 isotopeItem isotope-item">
<div class="isotopeWrapper clearfix isotope">
<article class="col-sm-4 isotopeItem isotope-item">
<!-- item1 --->
</article>
<article class="col-sm-4 isotopeItem isotope-item">
<!-- item2 --->
</article>
<!-- ... unknown amount of items with unknown height -->
</div>
这导致了一种“masonary”式的排列,其中行具有不同的位置绝对顶部位置。但是,这是不需要的,并且内容元素的高度未知(取决于用户输入)
我不太熟悉同位素/masonary类型的内容,并提出了以下问题:我如何才能让所有文章。同位素元素元素具有相同的高度(或者至少让每一行都有一条上实线?在我的例子中,没有动态添加/删除元素,因为这都是在服务器端完成的,需要完全重新加载页面。我假设这就是插件:
因此,只需使用fitRows
,每行的顶部就会对齐-
因此:
你不需要只使用fitRows
布局吗?它没有调整项目的高度,但它符合我的要求。谢谢你。你就是那个人!工作完美。有时你在拥挤的森林里看不到一棵树。我知道你的意思!很高兴这是对你的代码的一次非常轻松的更改:)
if($('.isotopeWrapper').length){
var $container = $('.isotopeWrapper');
var $resize = $('.isotopeWrapper').attr('id');
// initialize isotope
$container.isotope({
itemSelector: '.isotopeItem',
resizable: false, // disable normal resizing
masonry: {
columnWidth: $container.width() / $resize
}
});
var rightHeight = $('#works').height();
$('#filter a').click(function(){
$('#works').height(rightHeight);
$('#filter a').removeClass('current');
$(this).addClass('current');
var selector = $(this).attr('data-filter');
$container.isotope({
filter: selector,
animationOptions: {
duration: 1000,
easing: 'easeOutQuart',
queue: false
}
});
return false;
});
$(window).smartresize(function(){
$container.isotope({
// update columnWidth to a percentage of container width
masonry: {
columnWidth: $container.width() / $resize
}
});
});
}
// initialize isotope
$container.isotope({
itemSelector: '.isotopeItem',
resizable: false, // disable normal resizing
layoutMode: 'fitRows'
});