如何使用javascript更改元素的offsetHeight? [英] how to change the offsetHeight of a element using javascript?

查看:335
本文介绍了如何使用javascript更改元素的offsetHeight?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试更改元素的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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆