<!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=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body{
width:100%;
height:100%;
}
.right{
width:100px;
height:30px;
position:fixed;
top:100px;
right:100px;
pink;
}
.bottom{
width:900px;
height:30px;
margin:0 auto;
pink;
position:fixed;
left:auto;
bottom:;
} /*========================IE6兼容position:fixed属性的第一种方法===========*/
.center{
width:300px;
height:200px;
pink;
position:fixed;
top:100px;
left:100px;
_position:absolute;
_right:auto;
_left:expression(eval(document.documentElement.scrollLeft+100));
}
.top{
width:300px;
height:100px;
pink;
position:fixed;
top:;
right:400px;
_position:absolute;
_left:auto;
_right:expression(eval(document.documentElement.scrollRight+400));
}
.bottom1{
width:100px;
height:50px;
blue;
position:fixed;
right:50px;
bottom:100px;
_position:absolute;
_left:auto;
_bottom:expression(eval(document.documentElement.scrollBottom+100)); }
.top1{
width:200px;
height:200px;
red;
position:fixed;
top:20px;
right:50px; }
</style>
<!--==============IE6兼容position:fixed属性的第一种方法=============-->
<!--[if IE 6]>
<style type="text/css">
html{overflow:hidden}
body{height:100%;overflow:auto}
.right{position:absolute;}
.bottom{position:absolute;}
</style>
<![endif]-->
</head>
<body>
<div class="right">右边</div>
<div class="bottom">底部</div>
<div class="bottom1">底部1</div>
<div class="center">中间</div>
<div class="top">顶部</div>
<div class="top1">顶部1</div>
</body>
</html>

注意:Internet Explorer的CSS表达式(expression)。你不可以直接使用该表达式,因为它可能会因为缓存而不更新。解决这一点的最简单的方式是使用eval包裹你的语句。
html,* html body{background-image:url(about:blank);background-attachment:fixed}这个方法可以解决IE6振动BUG

/*让position:fixed在除IE6以外的主流浏览器可用! */
.fixed-top/* 头部固定 */{position:fixed;bottom:auto;top:0px;}
.fixed-left/* 左侧固定 */{position:fixed;right:auto;left:0px;}
.fixed-right/* 右侧固定 */{position:fixed;right:0px;left:auto;}
/*一下的是让position:fixed在IE6下可用! */
* html,* html body /* 修正IE6振动bug */{background-image:url(about:blank);background-attachment:fixed;}
* html .fixed-top/* IE6 头部固定 */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));}
* html .fixed-right/* IE6 右侧固定 */{position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));}
* html .fixed-bottom/* IE6 底部固定 */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}
* html .fixed-left/* IE6 左侧固定 */{position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft));}

From: http://lflianglan.blog.51cto.com/7020643/1217420

让IE6兼容position:fixed的更多相关文章

  1. css 兼容 position:fixed

    我是头 我是主体 有多少内容,我就有多高   我是脚 我要随滚动条滚动 我要随滚动条滚动 我要随滚动条滚动 <!DOCTYPE html PUBLIC "-//W3C//DTD XHT ...

  2. IE6下position:fixed;兼容

    *html{ background-image:url(about:blank); background-attachment:fixed;}/*解决抖动问题*/ .backto-top{ width ...

  3. IE6的position:fixed

    手头一个项目中,要实现把一个浮层控制在浏览器窗口右下角,用”position:fixed”来控制最合适不过了. 但万恶的IE6不支持这个属性,之前采用过的方法有:将滚动条转移到body上,使用绝对定位 ...

  4. IE6下position:fixed不支持问题及其解决方式

    IE6有诸多奇葩,不支持position:fixed就是当中之中的一个.所以在做一些比方固定在顶部或者底部或者固定元素的效果时须要考虑兼容IE6的这个问题.解决方式是用Ie6的hack. *html ...

  5. IE6中position:fixed无效问题解决

    在做页面右下脚对话框时,直接使用position:fixed;大部分浏览器很容易就能做到,但是在IE6中却发现不行,原来是IE6不支持position:fixed;这个属性. 虽然用JS肯定能解决这个 ...

  6. 让IE6支持position:fixed的方法,CSS expression与JavaScript eval讲解

    做吸顶效果或是固定效果时,使用position:fixed无非是最方便的,可是万恶的IE6是没有fixed这个属性值的,而我们要使IE6能够像fixed一样固定在浏览器中的某个位置,使用onscrol ...

  7. 小技巧css解决移动端ios不兼容position:fixed属性,无需插件

    移动端开发仿app头部底部固定设置position:fixed,android2.2以上已经实现.但是在ios8以下系统,当小键盘激活时,都会出现位置浮动问题.如图: 如何解决: 查阅资料之后想到一下 ...

  8. IOS系统不兼容position: fixed;属性的解决方案

    position: fixed;属性在IOS系统手机上会有很明显的抖动,解决方式: 只需要在中间部分外层div添加css样式position:fixed;top:50px; bottom:50px;o ...

  9. 打造IE6的position:fixed整理篇

    fixed真的是一个很好的属性.特别是做弹层的时候.可惜的是“国内主流浏览器”IE6大大不支持. 一般的我们都会通过CSS中的表达式来解决这个问题. .fixed { position:absolut ...

随机推荐

  1. 《C语言学习笔记》指针数组及其应用

    C语言中,最灵活但又容易出错的莫过于指针了.而指针数组,是在C中很常见的一个应用.指针数组的意思是说,这个数组存储的所有对象都为指针.除了存储对象为指针,即一个地址外,其它操作和普通数组完全一样. # ...

  2. linux根目录详解

    ubuntu 文件说明:http://tech.ccidnet.com/art/302/20080118/1347213_1.html/ 根目录  |  |-boot/ 启动文件.所有与系统启动有关的 ...

  3. jquery判断复选框是否选中

    jquery判断复选框是否被选中 $(function(){ $(document).on("click", ".checkbox",function(){ v ...

  4. 【python】三个变量互换值

    >>> x = 1>>> y = 2>>> z = 3>>> y3>>> z1 大写的帅字! (来自小甲鱼习题 ...

  5. slivelight5和数据库交互

    最近开始研究sliverlight和数据库交互了,无奈网上资料较少,查阅了大量资料终于成功了,但是我记得还有别的方法,希望大家讨论一下 数据访问层我的用的是ado.net实体数据模型 然后新建了一个w ...

  6. php自学笔记1

    PHP(Personal Home Page的缩写,现已更名Hypertext Preprocessor“超文本预处理器”)静态web开发:html,内容一成不变动态web开发: php(Zend). ...

  7. Http 状态码详解

    状态码 含义 100 客户端应当继续发送请求.这个临时响应是用来通知客户端它的部分请求已经被服务器接收,且仍未被拒绝.客户端应当继续发送请求的剩余部分,或者如果请求已经完成,忽略这个响应.服务器必须在 ...

  8. 二分法查找(Binary Search)

    --摘要:二分法的介绍已经很多了,但并不直观,因此此文诞生,希望批评指正. 二分查找是在有序数组中查找一个元素的算法,通过比较目标元素与数组中间元素来查找,如果目标值是中间元素则将返回中间元素位置. ...

  9. Hbase案例分析(一)

    Hbase应用场景: 1 随机读或者写 2 大数据上的高并发操作,比如每秒对PB级数据进行上千次操作.(查询,删除等操作) 3 读写均是非常简单的操作,比如没有join操作 Hbase Schema设 ...

  10. django入门教程(上)

    相信用过python的人都听过Django的大名,知道它是一个web框架,用来支持动态网站.网络应用程序以及网络服务的开发.那么为什么我们需要一个web框架,而不是直接用python来写web应用呢? ...