将 div 放在 div 中(我知道,它不起作用......)

发布于 2024-10-06 07:07:49 字数 509 浏览 9 评论 0原文

为什么这不起作用?它水平对齐正确,但在 Opera 中垂直对齐不正确。在 IE 中它根本不起作用。

http://img834.imageshack.us/img834/340/86238198.png

#footer
{
    position: absolute;
    top: 905px;
    width: 100%;
    min-width: 800px;
    height: 95px;
    margin: 0px;
    background-image: url('footerbg.png');
}

#center
{
    position: relative;
    width: 20%;
    height: 70%;
    margin: auto;

    background-color: red;
}

Why does this not work? It aligns horizontally correct, but not vertically in Opera. In IE it dosent work at all.

http://img834.imageshack.us/img834/340/86238198.png

#footer
{
    position: absolute;
    top: 905px;
    width: 100%;
    min-width: 800px;
    height: 95px;
    margin: 0px;
    background-image: url('footerbg.png');
}

#center
{
    position: relative;
    width: 20%;
    height: 70%;
    margin: auto;

    background-color: red;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独患者 2024-10-13 07:07:49

在过渡(怪异模式)下,IE 保持其旧版浏览器的行为,以免破坏在 IE 5 中构建为看起来不错的现有网站。因此,在 IE 6 及更高版本中,如果您没有定义严格的文档类型,那么它将诉诸其不尊重 margin:auto 的旧的错误行为。

In Transitional (quirks mode), IE maintains the behavior of its older browsers, so as to not break pre-existing websites that were constructed to look ok in IE 5. So in IE 6 and up, if you do not define a Strict doctype, then it will resort to its old incorrect behavior of not honoring margin:auto.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文