打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
解决IE6下Position:fixed问题
解决此问题的要点主要有: 
1).容器要有一个背景图片 
2).设置它的滚动属性为fixed。 
3).用IE特有的e­xpression方法计算出元素的top,left,right,bottom的量。 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
 <title>IE6 fixed</title>
 <style type="text/css">
 *
 {
 margin: 0px;
 padding: 0px;
 }
 body {
 _background-image: url(about:blank);     /*用浏览器空白页面作为背景*/
 _background-attachment: fixed;     /* prevent screen flash in IE6 确保滚动条滚动时,元素不闪动*/
 }
 
 #topNav {
 width: 980px;
 z-index: 100;                                                     /*设置浮动层次*/
 overflow: visible;
 position: fixed;
 top: 50px;                                                         /* 其他浏览器下定位,在这里可设置坐标*/
 _position: absolute;                                       /*IE6 用absolute模拟fixed*/
 _top: expression(documentElement.scrollTop + 50 + "px"); /*IE6 动态设置top位置*/
 /* documentElement.scrollTop 设置浮动元素始终在浏览器最顶,可以加一个数值达到排版效果 */
 background-color:#0000FF;
 height: 31px;
 }
 .show{
 position:absolute;
 top:500px;
 left:400px;
 border:#ff0000 1px solid;
 }
 </style>
 </head>
 <body>
 <div class="jd_menu" id="topNav">1111</div>
<div style="height:2000px"></div>
 <div class="show">show</div>
 <p>
  利用给<body>设置固定的背景,防止滚动条滚动时的闪动;如果<body>中要设置滚动的背景而产生冲突,可以把代码写在html选择器里面,如:
    html {
          _background-image: url(about:blank);
          _background-attachment: fixed;         /* prevent screen flash in IE6 */
    }
    body {
         background-image: url(1.jpg);
         background-attachment: scroll;
    }
 </p>
 </body>
 </html>
 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
轻轻松松学CSS:position
div当滚动到页面顶部的时候固定在顶部实例代码
css经典布局
div固定定位完美兼容如回顶部图标
css的属性position属性值的描述
Emulating Fixed Positioning
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服