开发者

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开发者_Go百科 help would be greatly appreciated.


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


Try this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜