【发布时间】:2018-07-03 12:00:26
【问题描述】:
我正在动态地将几个元素加载到页面中,所有元素都具有相同的标记结构。基本上这些产品都可以点击查看更多信息。
我正在使用 jQuery 获取最高实例的高度,并将该高度(+25px 填充)应用于所有实例,以保持一致的网格外观。
这适用于较小的屏幕,例如我的 13 英寸电脑,但是当我在大桌面上查看它时,实例加载时间过短,内容从底部溢出。
谁能指出我这里的修复方法?一如既往,非常感谢任何帮助!
这是我对每个实例的标记:
<a href="<?php the_permalink(); ?>">
<div class="product-archive-item">
<div class="product-archive-image"></div>
<h3><?php the_title(); ?></h3>
<span class="price"><?php $price(); ?></span>
</div> <!-- .product-archive-item -->
</a>
这是我的 jQuery:
var bigbrother = -1;
$('.product-archive-item').each(function() {
bigbrother = bigbrother > $('.product-archive-item').height() ? bigbrother : $('.product-archive-item').height() +25+'px';
});
$('.product-archive-item').each(function() {
$('.product-archive-item').height(bigbrother);
});
我还添加了两个屏幕之间差异的图片,以防万一。
【问题讨论】:
标签: jquery loops screen-resolution