Properti valign HTML DOM tr
Definisi dan Penggunaan
valign set properti atau data hasil di baris keselarasan vertikal.
tatabahasa
Pengaturan properti valign:
trObject.vAlign="baseline|bottom|middle|top"
Kembali sifat valign:
trObject.vAlign
值 | 描述 |
---|---|
baseline | 与基线对齐。 |
bottom | 对内容进行下对齐。 |
middle | 对内容进行下对齐。 |
top | 对内容进行上对齐。 |
Dukungan Browser
Semua browser utama mendukung properti valign
contoh
contoh
Contoh berikut mengubah susunan vertikal dari sel dalam data:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById('tr2').vAlign="top";
}
</script>
</head>
<body>
<table width="50%" border="1">
<tr id="tr1">
<th>第一个名称</th>
<th>下一个名称</th>
<th>文本</th>
</tr>
<tr id="tr2">
<td>Peter</td>
<td>Griffin</td>
<td>你好,我的名字叫Perter,我需要一个长文本来演示,我需要一个长文本来演示。</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('tr2').vAlign="top";
}
</script>
</head>
<body>
<table width="50%" border="1">
<tr id="tr1">
<th>第一个名称</th>
<th>下一个名称</th>
<th>文本</th>
</tr>
<tr id="tr2">
<td>Peter</td>
<td>Griffin</td>
<td>你好,我的名字叫Perter,我需要一个长文本来演示,我需要一个长文本来演示。</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">内容向上对齐</button>
</body>
</html>
Coba »
benda tr