HTML DOM 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>本教程(w3big.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>本教程(w3big.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>
嘗試一下»
Style對象