【发布时间】:2015-05-21 13:35:03
【问题描述】:
我有几个彼此相邻的<div> 元素,我想将它们的高度与最高的元素匹配。目前我是这样做的:
jQuery(function($) {
var maxHeight = 0;
$( ".services-area").each (function (index ) {
if (maxHeight < $( this ).height()) {
maxHeight = $( this ).height();
}
});
$( ".services-area").each (function (index ) {
$( this ).height(maxHeight);
});
})
有没有更好的方法来达到这个结果?
【问题讨论】:
-
如果您不介意与旧版浏览器不兼容,您可以使用 CSS flexbox。
-
为什么不使用表格...在这些情况下它可能会有所帮助
-
你解决了吗?我看到各种答案都通过了,但还没有接受。我的建议对您有帮助吗?
标签: javascript jquery html css dom