我最近学习了HTML,在表格居中时遇到了一些麻烦。由于我的项目中有两个高度相同的表格,因此我将一个表格设置为左对齐,另一个表格设置为居中对齐。由于它们位于相同的垂直位置,所以第一个表可以,但第二个表根据第一个表的右侧和网站右侧的距离居中。
我想知道如何将第二个表格居中,忽略第一个表格,使其根据网站中心居中,而不是根据表格和网站中心居中。
当前的代码是这样的:
<table align="left" width="300" bgcolor="#454545">
<tr height="65" bgcolor="565656" style="border-radius: 2%">
<td><center><img src="facebookLogo.png" width="65" height="65"></center></td>
<td><a href="https://www.facebook.com/somepagehere"><font size="4" color="#FFFFFF"> Like our page at Facebook!</font></a></td>
</tr>
<tr height="65" bgcolor="565656" style="border-radius: 2%">
<td><center><img src="twitterLogo.png" width="65" height="65"></center></td>
<td><a href="https://www.twitter.com/someaccouthere"><font size="4" color="#FFFFFF"> Follow us at Twitter!</font></a></td>
</tr>
<tr height="65" bgcolor="565656" style="border-radius: 2%">
<td><center><img src="youtubeLogo.png" width="65" height="65"></center></td>
<td><a href="https://www.youtube.com/someaccouthere"><font size="4" color="#FFFFFF"> Check us on Youtube!</font></a></td>
</tr>
<tr height="20">
</tr>
</table>
<table width="400" height="200" bgcolor="#000000" align="center">
<tr></tr>
</table>发布于 2014-03-02 10:38:37
一些注意事项:
<font>,<center>和bgcolor被弃用的原因。不要使用它们anymore.
正如@
查看
HTML:
<ul id="social">
<li>
<a href="https://www.facebook.com/somepagehere">
<img src="facebookLogo.png" width="65" height="65" />
Like our page at Facebook!
</a>
</li>
<li>
<a href="https://www.twitter.com/someaccouthere">
<img src="twitterLogo.png" width="65" height="65" />
Follow us at Twitter!
</a>
</li>
<li>
<a href="https://www.youtube.com/someaccouthere">
<img src="youtubeLogo.png" width="65" height="65" />
Check us on Youtube!
</a>
</li>
</ul>
<div id="other">
Foo bar
</div>CSS:
#social {
width: 300px;
background-color: #565656;
list-style: none;
padding: 0;
margin: 0;
position: absolute;
left: 0;
}
#social img {
vertical-align: middle;
}
#social a {
font-size: 18px;
font-weight: bold;
color: #fff;
}
#other {
width: 400px;
height: 200px;
margin: 0 auto;
background: #ffc;
}https://stackoverflow.com/questions/22122670
复制相似问题