我知道这个问题已被问过十亿次,但我查看了解决方案,但表格只是拒绝居中。我希望有人能帮助我。
这是我对 HTML 的看法:
<div id="paccount">
<table style="margin: 0 auto;">
<tr>
<td width="320" height="150">Order History</td>
<td width="28" rowspan="4"></td>
<td width="320" rowspan="4">Personal Information</td>
</tr>
<tr>
<td height="15"></td>
</tr>
<tr>
<td width="320" height="90">Preferences</td>
</tr>
<tr>
<td height="15"></td>
</tr>
<tr>
<td height="115" colspan="3">Logout</td>
</tr>
</table>
</div>
这是该 div 的 CSS:
#paccount {
width: 668px;
height: 400px;
background-color: transparent;
text-align:center;
}
编辑:对不起,我的意思是将文本居中放置在表格中。
最佳答案
您没有将表格居中。
您正试图将所有文本居中。
您必须先将 #paccount
div
居中。
这样做:
#paccount{
width:668px;
height:400px;
background-color: transparent;
margin:0 auto; /* Here is the key! */
}
关于html - table 根本不居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23883483/