JS實現(xiàn)控制表格單元格垂直對齊的方法

字號:


    這篇文章主要介紹了JS實現(xiàn)控制表格單元格垂直對齊的方法,涉及javascript操作表單元素樣式的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    本文實例講述了JS實現(xiàn)控制表格單元格垂直對齊的方法。分享給大家供大家參考。具體如下:
    下面的代碼控制指定的單元格靠底部垂直對齊
    <!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" 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>
    希望本文所述對大家的javascript程序設(shè)計有所幫助。