set equal height on multiple divs

前端 未结 5 1567
鱼传尺愫
鱼传尺愫 2020-12-21 15:49

I need to set equal height on a series of divs inside another div wrapper. The problem is that I dont want the same height on all of them. The page kind of have 3 columns an

5条回答
  •  青春惊慌失措
    2020-12-21 16:41

    I went with somethin like Peter suggested. I rewrote the plugin to:

    $.fn.cleverHeights = function(px) {
    $(this).each(function(){
        var currentTallest = 0;
        var width = 0;
        var row = new Array();
        $(this).children().each(function(i){
            if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
            width += parseInt($(this).outerWidth(), 10);
            row[++row.length] = $(this);
            if (width > 900) {
                $.each( row , function() {
                    $(this).css({'min-height': currentTallest});
                    // for ie6, set height since min-height isn't supported
                    if ($.browser.msie && $.browser.version == 6.0) { $(this).css({'height': currentTallest}); }
                });
                row.length = 0;
                width = 0;
                currentTallest = 0;
            }
        });
    });
    return this;
    };
    

    Thanks for the input

提交回复
热议问题