Jed*_*Jed 5 css formatting html5
我有以下HTML表格格式:
<table style="width: 100%;">
<tr>
<td>
//How to center this table within the parent-table cell?
<table style="width: 760px;">
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
由于HTML5不支持表的'align = center',我试图弄清楚如何在我上面的例子中为子表中的CSS模拟'align = center'.
我已经尝试过使用CSS margin属性而无济于事.
如何在上面的示例中居中子表?
Mik*_*keM 14
table {border:solid 1px #0f0}
table table {border:solid 1px #f00;margin: 0 auto}Run Code Online (Sandbox Code Playgroud)
<table style="width: 100%;">
<tr>
<td>
//How to center this table within the parent-table cell?
<table style="width: 760px;">
<tr>
<td>
Center This Table Dawg
</td>
</tr>
</table>
</td>
</tr>
</table>Run Code Online (Sandbox Code Playgroud)
margin:0 auto; 在这个例子中工作,在IE 7-9,FF 4,Chrome 11中测试/工作
小智 5
<table style="width: 100%;">
<tr>
<td>
<table style="width: 760px; margin: auto;">
<tr>
<td>
ss
</td>
</tr>
</table>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)