【发布时间】:2015-08-31 01:44:15
【问题描述】:
假设我的网站上有一个简单的表格
<table class="table table-striped table-bordered">
<tr>
<th>Name</th>
<th>Version</th>
<th>Edition</th>
<th>Expire Date</th>
<th>Owner</th>
</tr>
<tr>
<td style="color:red;">HomeX</td>
<td>1.83</td>
<td>Basic</td>
<td>13.07</td>
<td>All</td>
</tr>
</table>
我想从顶部移动它20px。我应该使用边距
margin-top:20px;
或者更好的使用绝对定位
position:absolute;
top:20px;
哪种方式更好?
【问题讨论】:
-
边距和定位是两个截然不同的主题..请阅读更多关于它们的信息并相应地做..
-
stackoverflow.com/questions/2189452/… 这可能对您有用。除非没有其他方法可以达到你想要的效果,否则不要使用绝对定位。否则,您应该在填充和边距之间做出决定,这个链接非常有帮助。
-
边距和绝对定位的最终结果截然不同。它们实际上绝不是彼此的替代品。所以你永远不应该问是使用边距还是绝对定位。
标签: html css css-position