繁体   English   中英

不同图像尺寸的Boostrap响应式网格问题

[英]Boostrap responsive grid issue with different images size

这是我的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

这里演示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM