首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >集中一个表时忽略其他表

问集中一个表时忽略其他表
EN

Stack Overflow用户
提问于 2014-03-02 09:18:38
回答 1查看 28关注 0票数 2

我最近学习了HTML,在表格居中时遇到了一些麻烦。由于我的项目中有两个高度相同的表格,因此我将一个表格设置为左对齐,另一个表格设置为居中对齐。由于它们位于相同的垂直位置,所以第一个表可以,但第二个表根据第一个表的右侧和网站右侧的距离居中。

我想知道如何将第二个表格居中,忽略第一个表格,使其根据网站中心居中,而不是根据表格和网站中心居中。

当前的代码是这样的:

代码语言:javascript
复制
<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">&nbsp; 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">&nbsp; 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">&nbsp; 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>
EN

回答 1

Stack Overflow用户

发布于 2014-03-02 10:38:37

一些注意事项:

  • 表应仅用于表格数据。事实并非如此,
  • 你应该把内容和表示分开。
    • 这就是为什么<font>,<center>和bgcolor被弃用的原因。不要使用它们anymore.

​

正如@

  • 所说,表格可以重叠。也许你有很宽的屏幕,但这并不意味着每个人都有。

查看

HTML:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
#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;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22122670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档