JavaScriptで、HTMLのテーブルのセル内の縦位置を行単位でHTMLのvalign属性で変更します。
【手順】
1.「023-TableRowVAlignJS.html」というファイルを作成。
2.「023-TableRowVAlignJS.html」を以下の様に入力。
<html>
<head>
</head>
<body>
<table id="table1" border="1">
<tr valign="top">
<td height="200">セル1-1</td>
<td height="200">セル1-2</td>
</tr>
<tr valign="center">
<td height="200">セル2-1</td>
<td height="200">セル2-2</td>
</tr>
<tr valign="bottom">
<td height="200">セル3-1</td>
<td height="200">セル3-2</td>
</tr>
</table>
<input type="button" value="top" onclick="javascript:table1.rows[0].vAlign='top';">
<input type="button" value="center" onclick="javascript:table1.rows[0].vAlign='center';">
<input type="button" value="bottom" onclick="javascript:table1.rows[0].vAlign='bottom';">
</body>
</html>
3.「023-TableRowVAlignJS.html」をブラウザで開きます。
4.以下の様に表示されれば成功です。
以上です。
-01.png)
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。