CSS - Equal Height Columns?

前端 未结 11 1115
情歌与酒
情歌与酒 2020-11-21 06:08

In CSS, I can do something like this:

But I\'ve no idea how to change that to something like:


Is this possible with CSS?

11条回答
  •  难免孤独
    2020-11-21 06:44

    You can do this easily with the following JavaScript:

    $(window).load(function() {
        var els = $('div.left, div.middle, div.right');
        els.height(getTallestHeight(els));
    }); 
    
    function getTallestHeight(elements) {
        var tallest = 0, height;
    
        for(i; i < elements.length; i++) {
            height = $(elements[i]).height();
    
            if(height > tallest) 
                tallest = height;
        }
    
        return tallest;
    };
    

提交回复
热议问题