本文介紹HTML colgroup align屬性指定列組中內(nèi)容的水平對齊方式。在 HTML5 中,不支持 <colgroup> align 屬性。
兩個<colgroup>元素,它們?yōu)楸碇械娜兄付ú煌膶R方式(請注意,第一個<colgroup>元素跨越兩列):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <colgroup> char 屬性使用-菜鳥教程(cainiaoplus.com)</title>
<style>table, th, td { border: 1px solid black;}</style>
</head>
<body>
<table style="width:100%">
<colgroup align="left"></colgroup>
<colgroup align="char" char="."></colgroup>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100.00</td>
</tr>
<tr>
<td>February</td>
<td>$10.00</td>
</tr>
</table>
</body>
</html>測試看看 ?/?IEFirefoxOperaChromeSafari
只有 Opera 和 Internet Explorer 8 及之前的版本(IE 9 不支持)支持 align 屬性(IE 9 不支持)。
在 HTML5 中,不支持 <colgroup> align 屬性。
align屬性指定列組中內(nèi)容的水平對齊方式。
<colgroup align="left|right|center|justify|char">
| 值 | 描述 |
|---|---|
| left | 左對齊內(nèi)容(默認值)。 |
| right | 右對齊內(nèi)容。 |
| center | 居中對齊內(nèi)容(th 元素的默認值)。 |
| justify | 對行進行伸展,這樣每行都可以有相等的寬度(就像在報紙和雜志中)。 |
| char | 將內(nèi)容對準指定字符。 |