clear

收藏:0   阅读:34

Style clear 属性


定义和用法

clear 属性设置或返回元素相对浮动对象的位置。

语法

设置 clear 属性:

Object.style.clear="none|left|right|both|inherit"

返回 clear 属性:

Object.style.clear

描述
none 默认。允许浮动对象出现在元素两侧。
left 不允许浮动对象出现在元素的左侧。
right 不允许浮动对象出现在元素的右侧。
both 不允许浮动对象出现在元素的左侧或右侧。
inherit clear 属性的值应该从父元素继承。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 clear 属性。

注意:IE7 及更早的版本不支持 "inherit" 值。IE8 只有规定了 !DOCTYPE 才支持 "inherit"。IE9 支持 "inherit"。


实例

不允许浮动对象出现在文本的左侧:

<html>
<head>
<style type="text/css">
img
{
float:left;
}
</style>
<script>
function displayResult()
{
document.getElementById("p1").style.clear="left";
}
</script>
</head>
<body>

<img src="w3javascript.gif" width="100" height="132">

<p id="p1">This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.</p>

<input type="button" onclick="displayResult()" value="Clear left side of text">

</body>
</html>

© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!