如何将此表格放到文档的中心? [英] How do I bring this table to the center of the doc?
问题描述
< table style =border:1px solid margin-left:20px; margin-right:20px; width:60%; background-color:#b0e0e6;>
< tr>
< td width =10%>
< b> I Rock< / b>
< br>< i> IN< / i>
< br>< / td>
< td width = 20%>
< ul>
< li>是的
< li>是的
< li>是的
< / ul>
< / td>
< / tr>
< / table>
<table style = "border:1px solid margin-left:20px; margin-right: 20px;width: 60%; background-color: #b0e0e6;">
<tr >
<td width="10%" >
<b>I Rock</b>
<br><i>IN</i>
<br></td>
<td width="20%">
<ul>
<li> yeah
<li> yeah
<li> yeah
</ul>
</td>
</tr>
</table>
推荐答案
这真的不是很显而易见的事情。
首先,尽量不要使用样式属性,使用CSS。这就是你的问题的解决方法:
This is really not a very obvious thing.
First of all, try not to use style attributes, use CSS. This is how your problem is solved:
table { margin-left: auto; margin-right: auto; /* remove other margin attributes */ }
查看其他款式,删除所有宽度
和其他 margin
属性,切换到内容宽度定义的宽度,使用填充
样式属性。如果您有其他表格与其他布局,请引入 class =center
并将属性类名称更改为,例如, table.center
。
Review other styles, remove all width
and other margin
attributes, switch to widths defined by content width, use padding
style properties. If you have other tables with other layout, introduce class="center"
and change the property class name to, say, table.center
.
table.center { margin-left: auto; margin-right: auto; /* ... */ }
HTML:
HTML:
<table class="center"> <!-- ... -->
</table>
这篇关于如何将此表格放到文档的中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!