HTML DOM Estilo propriedade de altura
Definição e Uso
conjuntos de propriedades altura ou retorna a altura do elemento.
altura atributo só desempenhar um papel no elemento em nível de bloco elementos ou uma posição absoluta / fixo. conteúdo atributo estouro estouro pode ser restrito.
gramática
Definir a propriedade height:
Object.style.height="auto|length|%|inherit"
atributos altura Back:
Object.style.height
值 | 描述 |
---|---|
auto | 默认。浏览器设置的高度。 |
length | 使用 px、cm 等单位定义高度。 |
% | 定义高度为父元素的百分比。 |
inherit | height 属性的值从父元素继承。 |
Suporte a navegadores
Todos os principais navegadores suportam atributos de altura.
Nota: IE7 e versões anteriores não suportam o valor "herdar".IE8 só fornece! DOCTYPE suportado "herdar". suporte IE9 "herdar".
Exemplos
Exemplos
Define a altura do botão:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("b1").style.height="50px";
}
</script>
</head>
<body>
<input type="button" id="b1" onclick="displayResult()" value="修改按钮高度">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("b1").style.height="50px";
}
</script>
</head>
<body>
<input type="button" id="b1" onclick="displayResult()" value="修改按钮高度">
</body>
</html>
tente »
estilo Objects