Latest web development tutorials

HTML DOM tr chOff 屬性

tr 對象參考手冊 tr對象

定義和用法

chOff 屬性可設置或者返回在行中單元格的對齊字符的偏移量。

chOff 屬性可通過attribute/ch 屬性字符設置內容字符的數量。

語法

設置chOff 屬性:

trObject.chOff="px|%"

返回chOff 屬性:

trObject.chOff

提示: chOff屬性沒有默認值。

描述
px 定义水平像素偏移
% 定义对象宽度的%的水平偏移量。


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流瀏覽器都支持chOff 屬性,但是,沒有任何主流瀏覽器實現該功能。


實例

實例

"Savings"列從右側對齊兩個字符:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</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()">字符对齐的水平偏移</button>
<p><b>注意:</b>不是所有主流浏览器都支持choff属性的功能。</p>

</body>
</html>

嘗試一下»


tr 對象參考手冊 tr對象