Equal Height Rows for Fluid Width Elements

前端 未结 2 982
执念已碎
执念已碎 2021-01-01 03:07

I\'ve used Chris Coyiers Equal Height Blocks in Rows jQuery script many times before, and it\'s always worked great.

That being said, I\'ve always developed website

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 03:36

    Assuming I understood your question, this code should work:

    $(document).ready(function() {
    
        $(window).on('resize', function() {
            $('.equalize').css('height', highest($('p')));
        }).trigger('resize');
    
    });
    
    function highest(el) {
        var highest = 0;
        el.each(function() {
            var height = $(this).height();
            if(height > highest) {
              highest = height;
            }
        });
        return highest;   
    }
    

    Fiddle

提交回复
热议问题