td/th chOff 屬性

td/th 對(duì)象參考手冊(cè) td/th 對(duì)象

定義和用法

chOff屬性設(shè)置或返回單元格的對(duì)齊字符的偏移量。

語法

設(shè)置 chOff 屬性:

tdObject.chOff="px|%"

或者

thObject.chOff="px|%"

返回 chOff 屬性:

tdObject.chOff

或者

thObject.chOff

提示: chOff 屬性沒有默認(rèn)值。

描述
px定義了水平偏移,以像素為單位
%使用百分比定義了水平偏移


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持 chOff 屬性, 但是,沒有任何主流的瀏覽器會(huì)執(zhí)行該此屬性的功能。


實(shí)例

實(shí)例

"Savings"列從"."的右側(cè)對(duì)齊兩個(gè)字符:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在線教程(w3cschool.cn)</title>
<script>
function displayResult(){
    var c=document.getElementById("myCol");
    alert("ch屬性的水平偏移為: " + c.chOff);
}
</script>
</head>
<body>

<table border="1">
    <colgroup>
        <col>
        <col id="myCol" align="char" char="." charoff="2">
    </colgroup>
    <tr>
        <th>月份</th>
        <th>存款</th>
    </tr>
    <tr>
        <td>January</td>
        <td>$100.00</td>
    </tr>
    <tr>
        <td>February</td>
        <td>$10.00</td>
    </tr>
</table>
<br>
<button type="button" onclick="displayResult()">字符對(duì)齊的水平偏移</button>
<p><b>注意:</b>不是所有主流瀏覽器都支持choff屬性的功能。</p>

</body>
</html>

嘗試一下 ?


td/th 對(duì)象參考手冊(cè) td/th 對(duì)象