gpt4 book ai didi

html - 具有不同图像大小的 Bootstrap 响应式网格问题

转载 作者:太空宇宙 更新时间:2023-11-04 12:39:56 25 4
gpt4 key购买 nike

这是我的 Boostrap 网格: http://i59.tinypic.com/nozn12.png

每张图片都有不同的尺寸,不幸的是,最高的一张将整行包裹起来,留下一个空白空间。我应该在每个图像中给出相同的尺寸,但我不能,因为这不是一个固定的布局。

这个问题有什么修复/解决方案吗?这是代码

<div class="row">

<div class="col-sm-6 col-md-3">
<div class="thumbnail">
<img src="temp/1.jpg" class="img-responsive">
<h4>4280 / 5PL</h4>
</div>
</div>

<div class="col-sm-6 col-md-3">
ecc.
</div>

<div class="col-sm-6 col-md-3">
ecc.
</div>
</div>

最佳答案

<div class="col-sm-6 col-md-3"> 使用等高

$.fn.eqHeights = function(options) {

var defaults = {
child: false
};
var options = $.extend(defaults, options);

var el = $(this);
if (el.length > 0 && !el.data('eqHeights')) {
$(window).bind('resize.eqHeights', function() {
el.eqHeights();
});
el.data('eqHeights', true);
}

if( options.child && options.child.length > 0 ){
var elmtns = $(options.child, this);
} else {
var elmtns = $(this).children();
}

var prevTop = 0;
var max_height = 0;
var elements = [];
elmtns.height('auto').each(function() {

var thisTop = this.offsetTop;

if (prevTop > 0 && prevTop != thisTop) {
$(elements).height(max_height);
max_height = $(this).height();
elements = [];
}
max_height = Math.max(max_height, $(this).height());

prevTop = this.offsetTop;
elements.push(this);
});

$(elements).height(max_height);
};

// run on load so it gets the size:
// can't have the same pattern for some reason or it scans the page and makes all the same height. Each row should be separate but it doesn't work that way.
$(window).load(function() {

//$('[class*="eq-"]').eqHeights();
$('.foo [class*="eq-"]').eqHeights();
$('.foo2 [class*="eq-"]').eqHeights();

});

使用<div class="row foo">对于 <div class="row">

并使用 col-sm-6 col-md-3 将 eq-col-sm-6 eq-col-md-3 类添加到所有 div

在这里DEMO

关于html - 具有不同图像大小的 Bootstrap 响应式网格问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26970715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com