Simulating position: fixed in IE6 with a div of 100% height?

旧巷老猫 提交于 2019-12-06 16:49:09

问题


I have a sidebar on my webpage that is supposed to span 100% of the page (vertically). It is then supposed to stay there, so when the rest of the content scrolls it does not. To do this, I used:

body
{
    height: 100%;
}

#sidebar
{
    height: 100%;
    width: 120px;
    position: fixed;
    top: 0;
    left: 0;
}

This works great in all modern browsers! Unfortunately, I have to code for IE6, which does not support position: fixed. Do you have any idea how I would do this?


回答1:


This is the fix »

Me? I'd just as soon use a more common navigation method, or use (gasp) frames.




回答2:


As stated here

  1. First, put IE6 into "standards mode" by using a strict DOCTYPE. Note that IE6's standards mode is known for its extremely odd quirks. We are taking advantage of one now.
  2. Use IE conditional comments to style the HTML and BODY tags like so:

    html, body {height:100%; overflow:auto;}

  3. Style anything you want to stay fixed as position:absolute.



来源:https://stackoverflow.com/questions/387485/simulating-position-fixed-in-ie6-with-a-div-of-100-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!