我怎样才能居中表格
A DIV
使用HTML内?
我已经把我的内容 DIV
标签中,并设置的text-align
属性中心
像下面这样。
文本对齐:中心;
这没有奏效。
下面是我的HTML。
< HTML>
<身体GT;
< DIV的风格=文本对齐:中心>
&其中p为H.;
文字测试
&所述; / P>
<表格边框=1>
&其中; TR>
&其中; TD> 100℃/ TD>
&其中; TD> 200℃; / TD>
&其中; TD> 300℃; / TD>
< / TR>
&其中; TR>
&其中; TD> 400℃; / TD>
&其中; TD> 500℃; / TD>
&其中; TD> 600℃; / TD>
< / TR>
< /表>
< / DIV>
< /身体GT;
< / HTML>
解决方案
给宽度表,并设置保证金自动水平。
表{
宽度:500px的;
保证金:10px的汽车;
}
How can I center the table
within a div
using html?
I have placed my content within a div
tag and set the text-align
attribute to center
like the following.
text-align: center;
This has not worked.
Below is my html.
<html>
<body>
<div style="text-align:center">
<p>
text test
</p>
<table border="1">
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
</table>
</div>
</body>
</html>
解决方案
Give width to table, and set margin auto horizontally.
table {
width:500px;
margin: 10px auto;
}
上一篇:碧玉报告 - 水平对齐动态文本字段和它们的标签碧玉、它们的、字段、文本
下一篇:我们什么时候需要使用代替的malloc posix_memalign?什么时候、malloc、posix_memalign