这是我的 fiddle :http://jsfiddle.net/rkfC9/
过去,当您可以简单地在 HTML 本身中编写时,它是如此容易,而使用 CSS 应该更容易,但对我来说没有任何效果。将此表中两行的内容居中的最简单方法是什么?
#table {
float:left;
}
#table td {
margin-left:auto;
margin-right:auto;
}
#brand {
width:40px;
height:40px;
background:red;
}
最佳答案
如果您将边距设置应用于内容,它将居中:
#brand {
margin-left:auto;
margin-right:auto;
width:40px;
height:40px;
background:red;
}
关于CSS3 : centering <td> with CSS only,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22023435/