HTML DOM propiedad Estilo marginRight
Definición y Uso
marginRight conjuntos de propiedades o devuelve los elementos adecuados desde el exterior.
gramática
Configuración de las propiedades marginRight:
Object.style.marginRight="%|length|auto|inherit"
Volver propiedades marginRight:
Object.style.marginRight
值 | 描述 |
---|---|
% | 定义基于父元素宽度的百分比右外边距。 |
length | 使用 px、cm 等单位定义右外边距的宽度。 |
auto | 浏览器设定的右外边距。 |
inherit | 右外边距从父元素继承。 |
Soporte para el navegador
Todos los principales navegadores soportan la propiedad marginRight.
Nota: Internet Explorer 7 y versiones anteriores no son compatibles con el valor "heredar".IE8 sólo proporciona! DOCTYPE apoyado "hereda". apoyo IE9 "hereda".
Notas y sugerencias
propiedades de los márgenes y las propiedades de relleno se insertan en el espacio alrededor del elemento. Sin embargo, la diferencia está, el margen se inserta en el espacio alrededor del exterior de la frontera, el espacio inserciones de relleno dentro de la frontera elemento.
Ejemplos
Ejemplos
Cambiar el elemento div del margen derecho:
<!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.marginRight="100px";
}
function changePadding(){
document.getElementById("ex2").style.paddingRight="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.marginRight="100px";
}
function changePadding(){
document.getElementById("ex2").style.paddingRight="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>
Trate »
Objetos de estilo