HTML 中的中心表格 [英] center table in HTML

查看:19
本文介绍了HTML 中的中心表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 html 将 table 置于 div 中?

我已将我的内容放在 div 标记中,并将 text-align 属性设置为 center,如下所示.

文本对齐:居中;

这没有用.

下面是我的 html.

<身体><div style="text-align:center"><p>文字测试</p><表格边框=1"><tr><td>100</td><td>200</td><td>300</td></tr><tr><td>400</td><td>500</td><td>600</td></tr>

解决方案

为表格提供宽度,并在水平方向上自动设置边距.

table {宽度:500px;边距:10px 自动;}

How can I center the table within a div using html?

I have placed my content within a div tag and set the text-align attribute to center like the following.

text-align: center;

This has not worked.

Below is my html.

<html>
    <body>
        <div style="text-align:center">
            <p>
    text test
            </p>
            <table border="1">
                <tr>
                    <td>100</td>
                    <td>200</td>
                    <td>300</td>
                </tr>
                <tr>
                    <td>400</td>
                    <td>500</td>
                    <td>600</td>
                </tr>
            </table>
        </div>
    </body>
</html>

解决方案

Give width to table, and set margin auto horizontally.

table {
  width:500px;
  margin: 10px auto;
}

这篇关于HTML 中的中心表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆