gpt4 book ai didi

javascript - 将一个高度加到另一个高度上

转载 作者:行者123 更新时间:2023-12-02 17:28:30 24 4
gpt4 key购买 nike

所以我有这段代码,它是找到三个 div 中最高的一个,获取它的高度并使用该高度来设置父 div,这非常有效,但现在我需要在另一个 div 的基础上添加更多内容,在另外 3 个彼此相邻的 div 下将有一个名为 #specation-bottom - 我需要将其高度添加到 #specification:

$(window).on('load resize',function(){
var maxHeight = -1;
$('.specification-columns').each(function() {
maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
});
$('#specification').each(function() {
$(this).height(maxHeight+24);
});
});

这是一个演示:http://zimxtrial.ukbigbuy.com/它位于规范部分,您将看到当前,#specation-bottom 位于其他 3 个的后面,一旦我将其高度添加到父级,它就会很好地适合,或者我希望如此.

最佳答案

试试这个:

$(window).on('load resize',function(){
var maxHeight = -1;
$('.specification-columns').each(function() {
maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
});
maxHeight += $('#specification-bottom').height(); // new line
$('#specification').each(function() {
$(this).height(maxHeight+24);
});
});

关于javascript - 将一个高度加到另一个高度上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23298082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com