gpt4 book ai didi

jquery - .outerHeight();获取十进制值?

转载 作者:行者123 更新时间:2023-11-29 18:40:40 26 4
gpt4 key购买 nike

是否可以获取.outerHeight();的十进制值

现在它返回一个四舍五入的值。

$(window).resize(function() {
var div_height_2 = $(".home-row-3-1").outerHeight();
$('.home-row-3-2').css("height", div_height_2);
$('.home-row-3-3').css("height", div_height_2);
});

最佳答案

并不保证您总是会得到 outerHeight() 整数或 float 的值。这取决于您的 HTML 结构和设备屏幕。 OuterHeight 获取匹配元素集中第一个元素的当前计算外部高度(包括填充、边框和可选的边距),或设置每个匹配元素的外部高度。

据官方documentation

The number returned by dimensions-related APIs, including .outerHeight(), may be fractional in some cases. Code should not assume it is an integer. Also, dimensions may be incorrect when the page is zoomed by the user; browsers do not expose an API to detect this condition.

The value reported by .outerHeight() is not guaranteed to be accurate when the element or its parent is hidden. To get an accurate value, ensure the element is visible before using .outerHeight(). jQuery will attempt to temporarily show and then re-hide an element in order to measure its dimensions, but this is unreliable and (even when accurate) can significantly impact page performance. This show-and-rehide measurement feature may be removed in a future version of jQuery.

关于jquery - .outerHeight();获取十进制值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57320251/

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