JS實現(xiàn)控制表格行內(nèi)容垂直對齊的方法
更新時間:2015年03月30日 15:06:09 作者:歐陽不瘋
這篇文章主要介紹了JS實現(xiàn)控制表格行內(nèi)容垂直對齊的方法,通過javascript的getElementById獲取元素并設(shè)置其相應(yīng)樣式來實現(xiàn)這一功能,需要的朋友可以參考下
本文實例講述了JS實現(xiàn)控制表格行內(nèi)容垂直對齊的方法。分享給大家供大家參考。具體分析如下:
下面的代碼通過表格的vAlign屬性控制表格行的內(nèi)容垂直對齊,可以置頂、可以居中、可以底部對齊
<!DOCTYPE html>
<html>
<head>
<script>
function topAlign()
{
document.getElementById('tr2').vAlign="top";
}
</script>
</head>
<body>
<table width="50%" border="1">
<tr id="tr1">
<th>Firstname</th>
<th>Lastname</th>
<th>Text</th>
</tr>
<tr id="tr2">
<td>Peter</td>
<td>Griffin</td>
<td>Hello my name is Peter Griffin.
I need a long text for this example.
I need a long text for this example.</td>
</tr>
</table>
<br>
<input type="button" onclick="topAlign()" value="Top-align table row" />
</body>
</html>
希望本文所述對大家的javascript程序設(shè)計有所幫助。
相關(guān)文章
JavaScript實現(xiàn)彈出模態(tài)窗體并接受傳值的方法
這篇文章主要介紹了JavaScript實現(xiàn)彈出模態(tài)窗體并接受傳值的方法,涉及JavaScript模態(tài)窗體的實現(xiàn)及基于URL的傳值操作技巧,需要的朋友可以參考下2016-02-02
xmlplus組件設(shè)計系列之文本框(TextBox)(3)
xmlplus 是一個JavaScript框架,用于快速開發(fā)前后端項目。這篇文章主要介紹了xmlplus組件設(shè)計系列之文本框,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05

