Equal height for two divs

前端 未结 5 1894
梦谈多话
梦谈多话 2020-12-21 05:20

I have 2 divs (6 columns each). In the div on the left is an image, in the div on the right is some quote. I want my right div\'s height to be the same as height of image.

5条回答
  •  盖世英雄少女心
    2020-12-21 06:02

    You can do this using jQuery

    Just add the class same-height to the DIV´s you want to have the same height

    jQUERY

    jQuery(document).ready(function($) { //noconflict wrapper
        var heights = $(".same-height").map(function() {
            return $(this).height();
        }).get(),
        maxHeight = Math.max.apply(null, heights);
        $(".same-height").height(maxHeight);
    });
    

提交回复
热议问题