HTML DOM content 屬性
定義和用法
content 屬性設(shè)置文本或圖像出現(xiàn)(浮動)在另一個元素中的什么地方。
語法:
Object.style.content=value
可能的值
值 | 描述 |
---|---|
string | 定義文本內(nèi)容。 |
url | 定義 url。 |
|
|
attr(X) | 定義顯示在該選擇器之前或之后的選擇器的屬性。 |
open-quote | |
close-quote | |
no-open-quote | |
no-close-quote |
提示和注釋
注釋:如果在一行中對于浮動元素而言空間太少,則這個元素會跳到下一行,這個過程會持續(xù)到有足夠空間的一行為止。
注釋:行內(nèi)元素的內(nèi)容、背景和邊框應(yīng)該出現(xiàn)在浮動元素之前。塊級元素的背景和邊框應(yīng)當出現(xiàn)在浮動元素之后,但是塊級元素的內(nèi)容應(yīng)當在浮動元素的前面。
實例
本例設(shè)置圖像浮動于左邊:
<html>
<head>
<script type="text/javascript">
function setFloatLeft()
{
document.getElementById("img1").style.cssFloat="left";
}
</script>
</head>
<body>
<img id="img1" src="logocss.gif" width="95" height="84" />
<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>
<form>
<input type="button" onclick="setFloatLeft()" value="Set image to float left" />
</form>
</body>
</html>