CSS div 跟随 IE7 中前一个 div 的宽度

发布于 2024-12-13 06:02:31 字数 687 浏览 2 评论 0原文

这是链接: www.guidegather.com

(抱歉,尝试发布图像但不能)

如果您查看页脚部分,它在所有主要浏览器(包括 IE9)中正确显示,但在 IE7 中,div#mainfooter 的宽度遵循最大宽度.center 类而不是水平延伸来填充空间。

CSS 如下:

.center{
    margin:0 auto;
    padding:0 50px;
        max-width:960px;
}
#mainfooter{
    background-color:#000;
    color:#CCC;
    list-style:none;
}

HTML 大致如下:

<body>
<div class="center">
Something here
</div>
<div id="mainfooter">
    <div class="center">
    Something here
    </div>
</div>
</body>

如您所见,div#mainfooter 独立于前一个 div,但宽度限制为前一个 div(和子 div)的最大宽度。有什么办法解决这个问题吗?

任何帮助表示赞赏。谢谢!

Here is the link :
www.guidegather.com

(sorry, tried posting image but cannot)

If you look at the footer section, it appears correctly in all major browser (including IE9) but in IE7, the width of the div#mainfooter follows the max-width of .center class instead of extending horizontally to fill the space.

Here is the CSS :

.center{
    margin:0 auto;
    padding:0 50px;
        max-width:960px;
}
#mainfooter{
    background-color:#000;
    color:#CCC;
    list-style:none;
}

Here is how the HTML roughly looks like :

<body>
<div class="center">
Something here
</div>
<div id="mainfooter">
    <div class="center">
    Something here
    </div>
</div>
</body>

As you can see, the div#mainfooter is independent of the previous div, but the width is restricted to the max-width of the previous div (and child div). Any solution to this?

Any help is appreciated. Thanks!

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

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

发布评论

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

评论(2

岁月流歌 2024-12-20 06:02:31

由于 #mainfooter 的规则将优先于任何继承的规则,因此您可以为 #mainfooter 指定宽度(width: 100%,或者除此之外,max-width: 100% )。那应该可以解决问题。

Since #mainfooter's rules will take priority over any inherited rules, you could specify a width for #mainfooter (width: 100%, or barring that, max-width: 100%). That should solve the problem.

寻梦旅人 2024-12-20 06:02:31

所以解决方案是在#mainfooter中添加display:block。希望这对将来遇到这个问题的人有所帮助,并非常感谢那些尝试帮助我的人

So the solution is to add display:block to #mainfooter. Hope this helps anyone facing this issue in the future and great thanks for those who tried helping me

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