<!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. nodejs -mysql模块链接数据库创建库创建表单。

    var mysql = require('mysql'); var connection= mysql.createConnection({ host:'localhost', user:'root' ...

  2. C#XML创建与节点对象引用

    我们在创建xml过程中会遇到不同的级别有相同节点的情况.如下面的xml: <?xml version="1.0" encoding="GBK"> & ...

  3. CentOS6.4 使用谷歌Chromium浏览器

    那么,如果希望在CentOS/RHEL 7出来之前继续使用Chrome怎么办?使用Chrome的开源版本:Chromium. 1.切换到root: su - 或者 sudo -i 2.下载新的软件源定 ...

  4. php 需熟练掌握的几个函数

    class Test { } $obj = new Test; 一.__construct() {}  构造函数 二.__destroy() {} 析构函数 三.__get() {} 试图读取一个并不 ...

  5. 如何在版本控制工具中管理Sencha Architect的項目

    根據數次痛苦的經歷結合stack overflow上的解答,發現原來還是可以使用svn.git之類的版本控制工具管理Sencha Architect生成的項目的. 具體的要點如下,假定項目記作{PRO ...

  6. 自己编写的sublime text 3 插件

    一些小功能,比较杂. 具体的功能在这里查看 1.本地环境的php运行结果获取. 2.快捷打开常用的文件,文件夹,url.(ctrl+shift+a) 3.常用的缩进转换. 下边是网络爬虫代码. #py ...

  7. 2016030208 - sql50题练习题

    数据库建表脚本和使用的数据请参考:http://www.cnblogs.com/zhtzyh2012/p/5235826.html sql50题练习参看:http://blog.sina.com.cn ...

  8. IEEE会议排名(转载)

    不知道谁整理的,我就下了个word.所以就标注不了,引用的哪的了. Rank 1: SIGCOMM: ACM Conf on Comm Architectures, Protocols & A ...

  9. comet ajax轮询

    http://www.ibm.com/developerworks/cn/webservices/ws-tip-jaxwsrpc.html http://www.cnblogs.com/pifoo/a ...

  10. POJ 1286 Necklace of Beads(Polya定理)

    点我看题目 题意 :给你3个颜色的n个珠子,能组成多少不同形式的项链. 思路 :这个题分类就是polya定理,这个定理看起来真的是很麻烦啊T_T.......看了有个人写的不错: Polya定理: ( ...