简体   繁体   English

调整与另一个Div相关的Divs高度

[英]Adjust Divs height related to another Div

I have four divs side by side. 我有四个div并排。 I'd like the height of them to be the same, and stay the same if one of them resizes. 我希望它们的高度相同,如果其中之一调整大小,则保持不变。 means, if one grows because text is placed into it, the other one should grow to match the height. 意思是,如果一个因为文本被放置而增长,则另一个应与高度匹配。

Here is my : Fiddle 这是我的: 小提琴

Please resize the width of answer 请调整答案的宽度

Thank you. 谢谢。

这是您应该使用display:flex的解决方案

jsfiddle.net/94uvouzw/7/
$(document).ready(function(){
    var height;
    var maxHeight = 0;
    $(".test").each(function(){
        height = $(this).height();
        if(height > maxHeight) {
            maxHeight = height;
        }
    });
    $(".test").css("height",maxHeight);
});

By using jQuery 通过使用jQuery

Demo Fiddle 演示小提琴

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

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