css – IE 6与位置:固定

前端之家收集整理的这篇文章主要介绍了css – IE 6与位置:固定前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
位置:修复,不适用于Internet Explorer 6.我无法真正理解谷歌上发现的修复程序.我需要它在IE6,IE7,IE8& FireFox 3.0.
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  3. <head>
  4. <Meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
  5. <title>Sidebar fixed</title>
  6. <style type="text/css">
  7. #wrapper {
  8. position:relative;
  9. width:900px;
  10. margin:0 auto 0 auto;
  11. }
  12. #sidebar_left {
  13. position:fixed;
  14. height:200px;
  15. width:200px;
  16. border:1px solid #000;
  17. }
  18. #sidebar_right {
  19. position:fixed;
  20. height:200px;
  21. width:200px;
  22. margin-left:700px;
  23. border:1px solid #000;
  24. }
  25. #content {
  26. position:absolute;
  27. height:2000px;
  28. width:480px;
  29. margin-left:210px;
  30. border:1px solid #000;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <div id="wrapper">
  36. <div id="sidebar_left">
  37. <p>Left sidebar</p>
  38. </div>
  39. <div id="sidebar_right">
  40. <p>Right sidebar</p>
  41. </div>
  42. <div id="content">
  43. <p>This is the content</p>
  44. </div>
  45. </div>
  46. </body>
  47. </html>

解决方法

不支持IE6!人们越早停止攻击IE6的网站,它将拥有的牵引力越小,死亡的速度就越快!或者,在第一个样式块之后添加代码;
  1. <!--[if IE 6]>
  2. <style type="text/css">
  3. #sidebar_right,#sidebar_left {
  4. position:absolute; /* position fixed for IE6 */
  5. top:expression(0+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px');
  6. left:expression(0+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');
  7. }
  8. </style>
  9. <![endif]-->

结果不是非常流畅,但确实有效.

UPDATE

我不太清楚如何使用它;只需将具有“position:fixed”的任何元素的id(或类)添加到上述块开头的声明列表中,它们将在IE6中表现自己.

猜你在找的CSS相关文章