當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


HTML DOM TFoot align屬性用法及代碼示例


HTML DOM TFoot align 屬性用於設置或返回 <thead> 元素內內容的水平對齊方式。 HTML 5 不支持它。

用法:

tfootObject.align = "left | right | center"

屬性值

  • left:它設置文本 left-align。
  • right:它設置文本 right-align。
  • center:它設置文本center-align。
  • justify:它拉伸段落的文本以設置所有行的寬度相等。
  • char:它將 text-align 設置為特定字符。

返回值:它返回一個字符串值,表示 <tfoot> 元素的水平對齊方式。



範例1:下麵的 HTML 代碼說明了如何返回 TFoot align 屬性。

HTML


<!DOCTYPE html>
<html>
<head>
    <style>
        table,
        th,
        td {
            border:1px solid green;
        }
    </style>
</head>
<body>
    <center>
        <h1>
           GeeksforGeeks
        </h1>
         
<p><b>HTML DOM TFoot align Property </b></p>
        <table>
            <thead>
                <tr>
                    <td>Username</td>
                    <td>User_Id</td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Shashank</td>
                    <td>@shashankla</td>
                </tr>
                <tfoot id="GFG" align="left">
                    <tr>
                        <td>GeeksforGeeks</td>
                        <td>@geeks</td>
                    </tr>
                </tfoot>
            </tbody>
        </table>
        <button onclick="btnclick()"> Click here </button>
        <p id="paraID"></p>
        </center>
        <script>
            function btnclick() {
                var x = document.getElementById("GFG").align;
                document.getElementById("paraID").innerHTML = x;
            }
        </script>
</body>
</html>

輸出:

範例2:下麵的 HTML 代碼說明了如何設置 TFoot align 屬性。

HTML


<!DOCTYPE html>
<html>
<head>
    <style>
        table,
        th,
        td {
            border:1px solid green;
        }
    </style>
</head>
<body>
    <center>
        <h1>
            GeeksforGeeks
        </h1>
         
<p><b>HTML DOM TFoot align Property </b></p>
        <table>
            <thead>
                <tr>
                    <td>Username</td>
                    <td>User_Id</td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Shashank</td>
                    <td>@shashankla</td>
                </tr>
                <tfoot id="GFG" align="left">
                    <tr>
                        <td>GeeksforGeeks</td>
                        <td>@geeks</td>
                    </tr>
                </tfoot>
            </tbody>
        </table>
        <button onclick="btnclick()"> Click here </button>
        <p id="paraID"></p>
        <script>
            function btnclick() {
                var x = document.getElementById("GFG").align = "right";
                document.getElementById("paraID").innerHTML = x;
            }
        </script>
</body>
</html>

輸出:




相關用法


注:本文由純淨天空篩選整理自ManasChhabra2大神的英文原創作品 HTML DOM TFoot align Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。