Style captionSide 屬性

定義和用法
captionSide 屬性設置或返回表格標題的位置。
語法
設置 captionSide 屬性:
Object.style.captionSide="top|bottom|inherit"
返回 captionSide 屬性:
Object.style.captionSide
值 | 描述 |
---|---|
top | 默認。把表格標題定位在表格之上。 |
bottom | 把表格標題定位在表格之下。 |
inherit | captionSide 屬性的值從父元素繼承。 |
流覽器支持
所有主要流覽器都支持 captionSide 屬性。
注意:IE7 及更早的版本不支持 captionSide 屬性。IE8 只有規定了 !DOCTYPE 才支持 captionSide 屬性。IE9 支持 captionSide 屬性。
實例
實例
把表格標題移到表格底部:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function displayResult(){
document.getElementById("myCap").style.captionSide="bottom";
}
</script>
</head>
<body>
<table border="1">
<caption id="myCap">My savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$150</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">移動表格標題</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function displayResult(){
document.getElementById("myCap").style.captionSide="bottom";
}
</script>
</head>
<body>
<table border="1">
<caption id="myCap">My savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$150</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">移動表格標題</button>
</body>
</html>
