CSS div 跟随 IE7 中前一个 div 的宽度
这是链接: 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于 #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.所以解决方案是在#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