简体   繁体   English

将所有div的大小调整为最高div的大小

[英]Resize all divs to the size of the tallest div

I have a div container class with a width of 15%. 我有一个div容器类,其宽度为15%。 Inside these containers I have image, the image has aa width of 100%. 在这些容器中,我有图像,图像的宽度为100%。 The problem is that not every image has the same ratio, so some container divs are longer then others which cause my layout to "crack". 问题在于,并非每个图像都有相同的比率,因此某些容器div的长度比其他容器更长,这导致我的布局“破裂”。

Is there a way to resize all the divs to the size of the tallest div? 有没有办法将所有div的大小调整为最高div的大小?

Loop through your divs using javascript find the max width. 使用javascript循环遍历div,找到最大宽度。 Then loop back through all the divs and set each width to the maxwidth that you found. 然后循环遍历所有div,并将每个宽度设置为找到的最大宽度。

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

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