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