propriété HTML DOM style marginBottom
Définition et utilisation
ensembles de propriétés marginBottom ou retourne l'élément suivant de l'extérieur.
grammaire
Définition des propriétés marginBottom:
Object.style.marginBottom="%|length|auto|inherit"
Retour propriétés marginBottom:
Object.style.marginBottom
值 | 描述 |
---|---|
% | 定义基于父元素宽度的百分比下外边距。 |
length | 使用 px、cm 等单位定义下外边距的宽度。 |
auto | 浏览器设定的下外边距。 |
inherit | 下外边距从父元素继承。 |
support du navigateur
Tous les principaux navigateurs prennent en charge la propriété marginBottom.
Note: IE7 et les versions antérieures ne supportent pas la valeur "inherit".IE8 ne fournit DOCTYPE! Supporté "inherit". soutien IE9 "inherit".
Trucs et astuces
propriétés de marge et les propriétés de remplissage sont insérés dans l'espace autour de l'élément. Cependant, la différence est, la marge sera insérée dans l'espace autour de l'extérieur de la frontière, des inserts de remplissage espace à l'intérieur de la frontière de l'élément.
Exemples
Exemples
Changer la marge inférieure de l'élément div:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<style type="text/css">
div{
border: 1px solid #FF0000;
}
</style>
<script>
function changeMargin(){
document.getElementById("ex1").style.marginBottom="100px";
}
function changePadding(){
document.getElementById("ex2").style.paddingBottom="100px";
}
</script>
</head>
<body>
<div id="ex1">这是一些文本。</div>
<br>
<button type="button" onclick="changeMargin()">修改div元素的底部外间距</button>
<br>
<br>
<div id="ex2">这是一些文本。</div>
<br>
<button type="button" onclick="changePadding()">修改div元素的底部内间距</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<style type="text/css">
div{
border: 1px solid #FF0000;
}
</style>
<script>
function changeMargin(){
document.getElementById("ex1").style.marginBottom="100px";
}
function changePadding(){
document.getElementById("ex2").style.paddingBottom="100px";
}
</script>
</head>
<body>
<div id="ex1">这是一些文本。</div>
<br>
<button type="button" onclick="changeMargin()">修改div元素的底部外间距</button>
<br>
<br>
<div id="ex2">这是一些文本。</div>
<br>
<button type="button" onclick="changePadding()">修改div元素的底部内间距</button>
</body>
</html>
Essayez »
style Objets