clear

設定物件是否允許在其左側、右側或兩側使用浮動物件,使隨後的文字顯示在浮動物件下方。

語法

{ clear: sClear }

可能的值

sClear

指定下列其中一個值的字串:

none

預設值。允許在兩側使用浮動物件。

both

將物件移至任何浮動物件的下方。

left

將物件移至位於左側之任何浮動物件的下方。

right

將物件移至位於右側之任何浮動物件的下方。

此屬性的預設值為 none 。這不是繼承屬性。

備註

此屬性的值列出不接受浮動物件的側邊。

範例

下列範例使用 clear 屬性來指定與浮動物件相對的文字位置。此範例會呼叫內嵌 (全域) 樣式表,以在遇到斜體文字時,將文字移至浮動物件下方:

<style>
    i { clear: left; }
</style>

此範例以段落左側的浮動物件為基準變更段落的相對位置:

<head><script>
function fnClear(){
    oClear.style.clear="left";
}
function fnClear2(){
    oClear.style.clear="none";
}
</script>
</head>
<body>
<img src="/workshop/graphics/sphere.jpg" style="float:left">
    <span id="oClear">
        <p>This is an example of the clear property.<p>
    </span>

    <p>
        <input type=button value ="clear = left" onclick="fnClear()"> 
        <input type=button value ="clear = none" onclick="fnClear2()">
    </p>
</body>

標準資訊

您可以在 World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 (全球資訊網協會 (W3C) 文件物件模組 (DOM) 層級 1) Ee371210.xtlink_newWindow(zh-tw,Expression.40).pngCascading Style Sheets (CSS), Level 1 (CSS1) (階層式樣式表 (CSS) 層級 1 (CSS1)) Ee371210.xtlink_newWindow(zh-tw,Expression.40).png 找到此屬性的定義。

適用範圍

a, address, applet, b, big, blockquote, button, caption, center, cite, code, col, colgroup, custom, dd, defaults, dfn, div, dl, dt, em, embed, fieldset, form, hn, hr, i, iframe, img, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, li, object, ol, option, p, s, select, span, sub, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var, xmp

另請參閱

概念

float