中心对齐一张桌子

时间:2012-12-12 22:54:11

标签: html css

如何使用css将页面居中对齐。这就是我http://jsfiddle.net/m5uEr/

<div style="text-align: center; border-style:solid;">
    <table style="border-style:solid;">
        <tr>
            <td>test</td>
        </tr>
    </table>
</div>

4 个答案:

答案 0 :(得分:2)

table.center {
    margin-left:auto; 
    margin-right:auto;
  }

<table style="border-style:solid;" class="center">
    <tr>
        <td>test</td>
    </tr>
</table>

Your updated fiddle

Google通过以下文字找到了我:“center align table css”

答案 1 :(得分:1)

在表格上设置宽度并设置

margin:auto

答案 2 :(得分:1)

css没有工作,所以我做了<table align="center">

这是在IE8上

答案 3 :(得分:1)

你有没有把margin-left:auto,margin-right:auto放在div的属性中?

这很容易做到。

这些属性应属于表

<div style="text-align: center; border-style:solid;">
    <table style="border-style:solid; margin-left:auto; margin-right:auto; ">
        <tr>
            <td>tdddest</td>
        </tr>
    </table>
</div>​