Style tableLayoutプロパティ
Style オブジェクト
定義と使い方
tableLayout プロパティは、テーブルのセル、行、列の表示アルゴリズムの規則を設定または返します。
構文
tableLayout プロパティを設定:
Object.style.tableLayout="automatic|fixed|inherit"
tableLayout プロパティを返す:
Object.style.tableLayout
| 值 | 説明 |
|---|---|
| auto | デフォルト。列幅はセルの内容によって設定されます。
|
| fixed | 列幅は、テーブルの幅と列幅によって設定されます(セルの内容によって設定されるわけではありません)。
|
| inherit | tableLayout プロパティの値は親要素から継承されます。 |
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが tableLayout プロパティをサポートしています。
注意:IE7 およびそれ以前のバージョンは "inherit" 値をサポートしていません。IE8 は !DOCTYPE が指定されている場合のみ "inherit" をサポートします。IE9 は "inherit" をサポートします。
例
例
固定テーブルレイアウトを設定:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
document.getElementById("myTable").style.tableLayout="fixed";
}
</script>
</head>
<body>
<table id="myTable" width="300" border="1">
<thead>
<th>表格表头</th>
<th>表格表头</th>
</thead>
<tbody>
<tr>
<td>これは一部のテキストです。これは一部のテキストです。</td>
<td>これは別のテキストです</td>
</tr>
</tbody>
</table>
<br>
<button type="button" onclick="displayResult()">固定テーブルレイアウトを設定</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
document.getElementById("myTable").style.tableLayout="fixed";
}
</script>
</head>
<body>
<table id="myTable" width="300" border="1">
<thead>
<th>表格表头</th>
<th>表格表头</th>
</thead>
<tbody>
<tr>
<td>これは一部のテキストです。これは一部のテキストです。</td>
<td>これは別のテキストです</td>
</tr>
</tbody>
</table>
<br>
<button type="button" onclick="displayResult()">固定テーブルレイアウトを設定</button>
</body>
</html>
試してみる »
Style オブジェクト その他の拡張