关键词搜索

源码搜索 ×
×

网页中位置固定块

发布2012-02-03浏览1988次

详情内容

想在页面中固定一个DIV,不随页面滚动,怎样做呢?

CSS

顶部:

  1. _html{background-image:url(about:blank);background-attachment:fixed;}
  2. #top{
  3. position:fixed;
  4. _position:absolute;
  5. top:0;
  6. _bottom:auto;
  7. _top:expression(eval(document.documentElement.scrollTop));
  8. }

底部:

  1. _html{background-image:url(about:blank);background-attachment:fixed;}
  2. #bottom{
  3. position:fixed;
  4. _position:absolute;
  5. bottom:0;
  6. _bottom:auto;
  7. _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
  8. }

有下划线(_)的是 CSS HACK,专门给IE6准备的。之所以要加上

_html{background-image:url(about:blank);background-attachment:fixed;}

是因为没有这句话,滚动的时候,固定块会闪动。


参考文章:

解决 IE6 position:fixed 固定定位问题





相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载