在HTML中心表中心、HTML

2023-09-11 23:32:56 作者:不问归期

我怎样才能居中表格 A DIV 使用HTML内?

我已经把我的内容 DIV 标签中,并设置的text-align 属性中心像下面这样。

 文本对齐:中心;
 

这没有奏效。

下面是我的HTML。

 < HTML>
    <身体GT;
        < D​​IV的风格=文本对齐:中心>
            &其中p为H.;
    文字测试
            &所述; / P>
            <表格边框=1>
                &其中; TR>
                    &其中; TD> 100℃/ TD>
                    &其中; TD> 200℃; / TD>
                    &其中; TD> 300℃; / TD>
                < / TR>
                &其中; TR>
                    &其中; TD> 400℃; / TD>
                    &其中; TD> 500℃; / TD>
                    &其中; TD> 600℃; / TD>
                < / TR>
            < /表>
        < / DIV>
    < /身体GT;
< / HTML>
 

解决方案

给宽度表,并设置保证金自动水平。

 表{
  宽度:500px的;
  保证金:10px的汽车;
}
 
HTML中如何设置下拉列表的宽度

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;
}

 
精彩推荐
图片推荐