gpt4 book ai didi

javascript - 如何检测元素是否具有 'auto' 高度

转载 作者:可可西里 更新时间:2023-11-01 02:25:19 27 4
gpt4 key购买 nike

无论 CSS 中设置的值如何,window.getComputedStyle(element).heightelement.clientHeight 都以像素为单位返回元素的当前高度。

有什么方法可以查明高度是设置为 auto 还是像素以外的其他单位?


@pvnarula 通过他链接的页面建议的一个解决方案是暂时 change the contents of the element, then compare heights .有点hacky...

最佳答案

请尝试:

document.getElementById("ele_id").style.height

同时检查以下插件:

http://gregpettit.ca/2012/jquery-check-if-element-has-auto-widthheight/

关于javascript - 如何检测元素是否具有 'auto' 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17044379/

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