Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
javascript中有没有办法确定Div的高度是否以%为单位
<div id="dvPercentage" style="height: 80%">
我如何得到 div 的高度以百分比给出。
只需访问元素样式对象的高度。
document.getElementById("objectId").style.height
这会回馈true
true
document.getElementById('dvPercentage').style.height.endsWith('%')
如果height是百分比。
height