HTML DOM cssFloat 屬性
定義和用法
設置文本或圖像出現(浮動)在另一個元素中的什么地方。
語法:
Object.style.cssFloat=left|right|none
可能的值
值 | 描述 |
---|---|
left | 圖像或文本浮動在父元素的左邊。 |
right | 圖像或文本浮動在父元素的右邊。 |
none | 圖像或文本浮動顯示在它在父元素中出現的位置。 |
提示和注釋
注釋:如果在一行中對于浮動元素而言空間太少,則這個元素會跳到下一行,這個過程會持續(xù)到有足夠空間的一行為止。
實例
本例設置圖像浮動于左邊:
<html>
<head>
<script type="text/javascript">
function setFloat()
{
document.getElementById("img1").style.cssFloat="left";
}
</script>
</head>
<body>
<img id="img1" src="logocss.gif" />
<p>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="setFloat()"
value="Set image to float to the left" />
</body>
</html>
TIY
- cssFloat - 設置圖像浮動于文字的左邊(請在非 IE 瀏覽器中查看)