模拟位置:是否已固定在IE6中,高度为100%? [英] Simulating position: fixed in IE6 with a div of 100% height?

查看:88
本文介绍了模拟位置:是否已固定在IE6中,高度为100%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页上有一个侧边栏,该侧边栏应该(垂直)跨越页面的100%。然后应该将其保留在那里,因此当其余内容滚动时,它就不会停留。为此,我使用了以下方法:

  body 
{
身高:100%;
}

#sidebar
{
高度:100%;
宽度:120像素;
头寸:固定;
top:0;剩余
:0;
}

这在所有现代浏览器中都很好用!不幸的是,我不得不为不支持位置的IE6编写代码:已修复。您知道我该怎么做吗?

解决方案

如所述此处


  1. 首先,使用严格的DOCTYPE将IE6置于标准模式。请注意,IE6的标准模式以其非常奇怪的怪癖而闻名。我们现在正在利用一个。

  2. 使用IE条件注释来设置HTML和BODY标签的样式,如下所示:



    html,body {height:100 %;

  3. 设置要固定位置的样式为绝对位置。



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?

解决方案

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.

这篇关于模拟位置:是否已固定在IE6中,高度为100%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆