简体   繁体   English

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

[英]I can't seem to figure out how to center align my table

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

I am not good with coding. 我不擅长编码。 I've tried but cannot figure it out. 我已经尝试但无法弄明白。 Your help would be greatly appreciated. 非常感谢您的帮助。

Try this: 尝试这个:

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

Or if you want to style inline: 或者,如果您想要内联样式:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM