propriedade HTML DOM Estilo minWidth
Definição e Uso
MinWidth conjuntos de propriedades ou retorna a largura mínima de um elemento.
Propriedades MinWidth desempenhar um papel apenas no elemento ou elementos de posição absoluta / fixo em nível de bloco.
gramática
Definindo as propriedades minWidth:
Object.style.minWidth="length|%|inherit"
Propriedades volta minWidth:
Object.style.minWidth
值 | 描述 |
---|---|
length | 使用 px、cm 等单位定义最小宽度。默认是 0。 |
% | 定义最小宽度为父元素的百分比。 |
inherit | minWidth 属性的值从父元素继承。 |
Suporte a navegadores
Todos os principais navegadores suportam minWidth propriedade.
Nota: IE7 e versões anteriores não suportam o valor "herdar".IE8 só fornece! DOCTYPE suportado "herdar". suporte IE9 "herdar".
Exemplos
Exemplos
A largura mínima do elemento:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.minWidth="200px";
}
</script>
</head>
<body>
<p style="background:red;width:100px;" id="p1">这个段落的宽度是100px。<br>
当点击下面的按钮时,<br>
最小宽度被设置为200px,<br>
因此,这一个段落是200像素宽</p>
<input type="button" onclick="displayResult()" value="设置最小宽度">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.minWidth="200px";
}
</script>
</head>
<body>
<p style="background:red;width:100px;" id="p1">这个段落的宽度是100px。<br>
当点击下面的按钮时,<br>
最小宽度被设置为200px,<br>
因此,这一个段落是200像素宽</p>
<input type="button" onclick="displayResult()" value="设置最小宽度">
</body>
</html>
tente »
estilo Objects