tr vAlignプロパティ
tr オブジェクト
定義と用法
vAlign プロパティは、行内のデータの垂直方向の配置を設定または返します。
構文
vAlign プロパティを設定する:
trObject.vAlign="baseline|bottom|middle|top"
vAlign プロパティを返す:
trObject.vAlign
| 值 | 説明 |
|---|---|
| baseline | ベースラインに整列します。 |
| bottom | コンテンツを下揃えします。 |
| middle | コンテンツを下揃えします。 |
| top | コンテンツを上揃えします。 |
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは vAlign プロパティをサポートしています。
例
例
次の例では、セル内のデータの垂直方向の配置を変更します。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.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>サンプル(example.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>
試してみる »
tr オブジェクト その他の拡張