举报投诉联系我们 手机版 热门标签 编程学
您的位置:编程学 > htmlstyle属性的用法 HTML DOM Style clear 属性

htmlstyle属性的用法 HTML DOM Style clear 属性

2023-06-15 18:18

htmlstyle属性的用法 HTML DOM Style clear 属性

htmlstyle属性的用法 HTML DOM Style clear 属性

htmlstyle属性的用法

Style clear 属性

Style 对象参考手册 Style 对象

定义和用法

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>



Style 对象参考手册 Style 对象
阅读全文
以上是编程学为你收集整理的htmlstyle属性的用法 HTML DOM Style clear 属性全部内容。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
相关文章
© 2024 编程学 bianchengxue.com 版权所有 联系我们
桂ICP备19012293号-7 返回底部