這篇文章主要介紹了JS實(shí)現(xiàn)控制表格單元格垂直對(duì)齊的方法,涉及javascript操作表單元素樣式的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了JS實(shí)現(xiàn)控制表格單元格垂直對(duì)齊的方法。分享給大家供大家參考。具體如下:
下面的代碼控制指定的單元格靠底部垂直對(duì)齊
<!DOCTYPE html>
<html>
<head>
<script>
function valignCell()
{
var x=document.getElementById('myTable').rows[0].cells;
x[0].vAlign="bottom";
}
</script>
</head>
<body>
<table id="myTable" border="1" height="70%">
<tr>
<td>First cell</td>
<td>Second cell</td>
</tr>
<tr>
<td>Third cell</td>
<td>Fourth cell</td>
</tr>
</table>
<form>
<input type="button" onclick="valignCell()"
value="Vertical align cell content">
</form>
</body>
</html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
更多信息請(qǐng)查看IT技術(shù)專欄