位置:修复,不适用于Internet Explorer 6.我无法真正理解谷歌上发现的修复程序.我需要它在IE6,IE7,IE8& FireFox 3.0.
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
- <head>
- <Meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
- <title>Sidebar fixed</title>
- <style type="text/css">
- #wrapper {
- position:relative;
- width:900px;
- margin:0 auto 0 auto;
- }
- #sidebar_left {
- position:fixed;
- height:200px;
- width:200px;
- border:1px solid #000;
- }
- #sidebar_right {
- position:fixed;
- height:200px;
- width:200px;
- margin-left:700px;
- border:1px solid #000;
- }
- #content {
- position:absolute;
- height:2000px;
- width:480px;
- margin-left:210px;
- border:1px solid #000;
- }
- </style>
- </head>
- <body>
- <div id="wrapper">
- <div id="sidebar_left">
- <p>Left sidebar</p>
- </div>
- <div id="sidebar_right">
- <p>Right sidebar</p>
- </div>
- <div id="content">
- <p>This is the content</p>
- </div>
- </div>
- </body>
- </html>
解决方法
不支持IE6!人们越早停止攻击IE6的网站,它将拥有的牵引力越小,死亡的速度就越快!或者,在第一个样式块之后添加此代码;
- <!--[if IE 6]>
- <style type="text/css">
- #sidebar_right,#sidebar_left {
- position:absolute; /* position fixed for IE6 */
- top:expression(0+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px');
- left:expression(0+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');
- }
- </style>
- <![endif]-->
结果不是非常流畅,但确实有效.
UPDATE
我不太清楚如何使用它;只需将具有“position:fixed”的任何元素的id(或类)添加到上述块开头的声明列表中,它们将在IE6中表现自己.