我似乎无法弄清楚如何对齐我的桌子

时间:2011-09-30 19:47:54

标签: html-table alignment center

<table border="0" align="center">
<tbody>
<tr>
<td>Cell1</td>
<td>Cell1</td>
</tr>
<tr>
<td>Cell1</td>
<td>Cell1</td>
</tr>
<tr>
<td>Cell1</td>
<td>Cell1</td>
</tr>
<tr>
<td>Cell1</td>
<td>Cell1</td>
</tr>
</tbody>
</table>

我不擅长编码。我已经尝试但无法弄明白。非常感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

试试这个:

<div style="width: 100%; text-align: center;">
    <!-- Your table here -->
</div>

答案 1 :(得分:1)

// CSS:

#container {
    text-align:center; // needed if you expect IE 5
}

.centered {
    margin:0px auto; // this sets left/right margin to auto and
                     // centers the element
}


// HTML:

<div id="container">
    <table class="centered" border="0">
        ...
    </table>
</div>

或者如果你想内联样式:

<div style="text-align:center;">
    <table style="margin:0px auto;" border="0">
        ...
    </table>
</div>
相关问题