当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。