2011-09-30 78 views
0
<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> 

我不擅长编码。我试过了,但无法弄清楚。你的帮助将不胜感激。如果你想风格的行内我似乎无法弄清楚如何居中对齐我的表格

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

回答

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> 

或者:

+0

Yaaay!样式内联建议工作。谢谢丹尼斯! –

+0

不客气。请不要犹豫,将其标记为已回答。 –

+0

不适合我;( –

1

试试这个

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

谢谢,但没有奏效。我正在使用wordpress。我输入代码并将表格居中在管理区域中。但是当我去到网站并刷新页面时,表格仍然在页面的左侧。 –

+0

@JackStevens看起来像这将是一个有用的信息在你的问题。 –

+0

也谢谢你的帮助杰夫。丹尼斯式的内联建议效果很好。谢谢。 Yaayay! –

相关问题