IE7 和固定 div 问题
背景
我需要使用固定 DIV 为客户端做一个相当复杂的布局。 IE8、FF3 和 Chrome 中一切都很好,但 IE7 破坏了所有内容
编辑:固定 DIV 是必须的,只有内容 DIV 必须滚动(这是规范,抱歉)
HTML 和 CSS 代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>
test
</title>
<!--[if lt IE 8]>
<![endif]-->
<!--[if lt IE 7]>
<![endif]-->
</head>
<body style="margin: 10px;">
<div id="wrapper" style="width: 960px; margin: 0 auto; position: relative; border: 1px solid red; overflow: hidden;">
<div id="header" style="position: fixed; width: 185px; height: 600px; top: 10px; border: 1px solid blue;">
header
</div>
<div id="content" style="width: 680px; float: left; background: white; margin-left: 185px; min-height: 600px; border: 1px solid lime;">
content
</div>
<div id="rightcolumn" style="position: fixed; top: 10px; width: 90px; margin-left: 865px; height: 600px;border: 1px solid maroon;">
right
</div>
</div>
</body>
</html>
宽度 IE8、FF3 和 Chrome
IE8、FF3 和 Chrome http://img39.imageshack.us /img39/406/firefoxkpd.jpg
宽度 IE7
IE7 http://img23 .imageshack.us/img23/1315/ie7l.jpg
注释
我不太担心 IE6,因为我知道它不支持 Fixed
元素,但如果你知道如何修复它, 伟大的!
问题
- 我应该了解有关 IE7 错误的哪些信息才能解决该问题?
- 如何相对于包装器引用标题列中的左侧
- 为什么标题列向右移动,而右列消失?
Background
I need to do a rather complex layout for a client, using fixed DIV. Everything is fine in IE8, FF3 and Chrome, but IE7 mangles all the thing
Edit: The fixed DIVs are a must, only the content DIV must scroll (That is the spec, sorry)
HTML and CSS code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>
test
</title>
<!--[if lt IE 8]>
<![endif]-->
<!--[if lt IE 7]>
<![endif]-->
</head>
<body style="margin: 10px;">
<div id="wrapper" style="width: 960px; margin: 0 auto; position: relative; border: 1px solid red; overflow: hidden;">
<div id="header" style="position: fixed; width: 185px; height: 600px; top: 10px; border: 1px solid blue;">
header
</div>
<div id="content" style="width: 680px; float: left; background: white; margin-left: 185px; min-height: 600px; border: 1px solid lime;">
content
</div>
<div id="rightcolumn" style="position: fixed; top: 10px; width: 90px; margin-left: 865px; height: 600px;border: 1px solid maroon;">
right
</div>
</div>
</body>
</html>
Width IE8, FF3 and Chrome
IE8, FF3 and Chrome http://img39.imageshack.us/img39/406/firefoxkpd.jpg
Width IE7
IE7 http://img23.imageshack.us/img23/1315/ie7l.jpg
Notes
I'm not so worried about IE6 because I know it does not support Fixed
elements, but if you know how to fix it, great!
Questions
- What should I know about IE7 bugs to fix the problem?
- How can I reference the left in the header columns relatively to the wrapper
- Why the header column goes the the right and the right column disappears?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果基于脚本的解决方案可以接受,那么我已经使用 Dean Edwards 的 升级脚本,修补 IE 行为,使其更像标准所示。
If script-based solutions are acceptable, then I have had some success with fixed divs (not necessarily using the layout you have) using Dean Edwards' upgrade scripts which patch IE behaviours to be more like the standards indicate.
应该这样做!
That should do it!
固定位置在旧版浏览器中不起作用。 您可以将元素浮动到彼此旁边。
还为正文指定零填充,Opera 使用默认填充而不是边距(这实际上更有意义)。
我将样式放在样式表中以使代码更清晰:
The fixed position doesn't work in older browsers. You can float the elements beside each other.
Specify a zero padding for the body also, Opera uses a default padding instead of margin (which actually makes more sense).
I put the styles in a style sheet to make the code cleaner:
怎么样:
它适用于 IE7、Firefox、Opera、Safari 和 Chrome。 我想它也可以在 IE6 和 IE8 中运行。
我必须减少“内容”的宽度,因为 (rightcolumn+content+header) < 包装纸
What about this:
It works on IE7, Firefox, Opera, Safari and Chrome. I guess it will work in IE6 and IE8 too.
I had to reduce the width of the "content" because the (rightcolumn+content+header) < wrapper
找到了修复!!奇怪的是,将内容浮动到
右侧
修复了它!我能赚到一块饼干吗?
Found a fix!! Strange enough floating the content to
right
fixes it!Do I earn a cookie?