Simulating position: fixed in IE6 with a div of 10

2020-08-03 12:59发布

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?

2条回答
【Aperson】
2楼-- · 2020-08-03 13:33

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.

查看更多
\"骚年 ilove
3楼-- · 2020-08-03 13:52

This is the fix »

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

查看更多
登录 后发表回答