<!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. 如何在WCF中集成unity

    第一种是代码方式: 点击打开链接http://blogs.microsoft.co.il/gadib/2010/11/30/wcf-and-unity-20/ 还有一种方式可以扩展成配置文件,有时间再 ...

  2. PHP 读json文件并转php配置文件

    <?php$c = file_get_contents('./cities_v2.json');$s = "<?php return " . var_export(js ...

  3. Quartz2D学习笔记(1)

    ********************************** 简介 *************************************** Quartz2D是⼀个二维绘图引擎,同时支持 ...

  4. 在ADS上由于volatile惹得祸

    C语言关键字volatile是一个危险的东东,笔者再用ADS做S3C2440定时器中断实验就因为这个关键字出了错.出现错误情况的准确描述是:定义一个变量时没有用volatile关键字,而且紧接着whi ...

  5. 黑马程序员-------.net基础知识二

    变量 变量代表着一块内存空间,我们可以通过变量名称想内存存/取数据,有变量就不需要我们记忆复杂的内存地址. 向内存中申请一块内存空间的语法:   数据类型 变量名; 变量类型 变量类型 存储位置 自动 ...

  6. swift 语法 - 以及学习资料

    附上一些swift的一下学习资料: 1.Swift语法介绍官方英文版:The Swift Programming Language 2.Swift与Objective-C相互调用Using Swift ...

  7. asp.net mvc4 Controller与Action执行过程的研究(学习笔记)

    当IIS收到一个http请求,把请求信息发给对应的HttpModel(实际是实现类UrlRoutingModule),在HttpModel中会注册HttpApplication 类中的PostReso ...

  8. CSS标签居中

    CSS标签居中是相对于父标签说的,即在父标签的中居中.通常是在子标签中使用margin:0 auto,来使子标签居中.此外子标签需要有固定的宽度才行,比如 子标签为div时,div的宽度默认占父标签的 ...

  9. using namespace std

    using namespace std std 是一个命名空间..不同的命名空间可以有相同的类名被定义 ..using namespace std;就是指明下面的程序使用std,如果不用这句指明的话就 ...

  10. C#编译器对于dynamic对象到底做了什么

    private static void TestMethod() { //dynamic 仅仅是个占位符而已 dynamic p1 = , Y = }; //对dynamic对象p1的X属性访问通过C ...