Style clearPropiedad
Objeto Style
Definición y uso
La propiedad clear establece o devuelve la posición del elemento en relación con los objetos flotantes.
Sintaxis
Establecer la propiedad clear:
Object.style.clear="none|left|right|both|inherit"
Devolver la propiedad clear:
Object.style.clear
| Valor | Descripción |
|---|---|
| none | Predeterminado. Permite que los objetos flotantes aparezcan a ambos lados del elemento. |
| left | No permite que los objetos flotantes aparezcan en el lado izquierdo del elemento. |
| right | No permite que los objetos flotantes aparezcan en el lado derecho del elemento. |
| both | No permite que los objetos flotantes aparezcan a la izquierda o derecha del elemento. |
| inherit | El valor de la propiedad clear debe heredarse del elemento padre. |
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten la propiedad clear.
Nota:IE7 y versiones anteriores no admiten el valor "inherit". IE8 solo admite "inherit" si se especifica el !DOCTYPE. IE9 admite "inherit".
Ejemplo
Ejemplo
No permite que los objetos flotantes aparezcan a la izquierda del texto:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de Ejemplo (example.com)</title>
<style type="text/css">
img {
float:left;
}
</style>
<script>
function displayResult(){
document.getElementById("p1").style.clear="left";
}
</script>
</head>
<body>
<img src="w3javascript.gif.html" width="100" height="132">
<p id="p1">Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto.</p>
<input type="button" onclick="displayResult()" value="Flotar el texto a la izquierda">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de Ejemplo (example.com)</title>
<style type="text/css">
img {
float:left;
}
</style>
<script>
function displayResult(){
document.getElementById("p1").style.clear="left";
}
</script>
</head>
<body>
<img src="w3javascript.gif.html" width="100" height="132">
<p id="p1">Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto. Este es un texto.</p>
<input type="button" onclick="displayResult()" value="Flotar el texto a la izquierda">
</body>
</html>
Pruébalo »
Objeto Style Otras extensiones