在HTML中心表 [英] center table in HTML
本文介绍了在HTML中心表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能居中表格
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;
}
这篇关于在HTML中心表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文