问题描述
您好我正在尝试更改元素的offsetHeight。我使用以下
Hello i'm trying to change the offsetHeight of an element. i used the following
document.getElementById('id').style.offsetHeight = 0;
但我看到没有明显的变化。有人可以帮我吗?
but i saw no visible change. Can anyone help me please?
推荐答案
offsetHeight
属性表示高度元素的可见区域。它是一个简写,包含填充,滚动条和边框的维度总和。
The offsetHeight
property indicates the height of the visible area for an element. It's a shorthand that contains the sum of dimensions from padding, scrollbars and borders.
但是,它不能用于更改实际大小,如评论中所述, offsetHeight
是元素的属性,而不是样式。
However, it can't be used to change the actual size and as noted in comments, offsetHeight
is a property of an element, not style.
要修改实际大小,请使用 height
, padding
或 border
。
To modify the actual size use height
, padding
or border
.
这篇关于如何使用javascript更改元素的offsetHeight?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!