当前位置: 首页 > 图文教程 > 网页制作 > CSS样式表 > CSS教程:兼容ie6,ie7,ff的fixed

CSS样式表
人们期待的CSS3的10大功能
网页设计过程中推荐的命名规范
漂亮样式表在XHTML+CSS网页制作中的应用
10个非常有用但是IE浏览器不能使用的CSS属性
CSS教程:div仿框架方法
CSS实例:CSS制作的像素图
点击网页超级链接虚线怎么去除?
CSS网页布局的一些常见规则
CSS教程:overflow与text-indent:-9999px
CSS样式表在网页设计中的4个特性
haslayout是什么意思
CSS教程:让IE6支持position:fixed
用css实现表格外观的无序列表
替换和不可替换元素以及显示元素
CSS属性选择器制作个性化链接样式
Webjx推荐15个好的CSS网格布局生成器
html教程:pre标记里内容自动换行
CSS技巧教程:css书写技巧
css教程:DIV布局网页的常见错误
IE中img多出5px的空白解决4种方法

CSS样式表 中的 CSS教程:兼容ie6,ie7,ff的fixed


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 112 ::
收藏到网摘: n/a

效果地址:


[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

出处:http://xiebiji.com/2009/09/fixed

为了兼容ie6(万恶的东西),用的是expression的方法

在页头加入:

<style type="text/css">
body{	background-image:url(about:blank); background-attachment:fixed;/*必要,防抖动*/
}
.head,.foot{	position:fixed !important;/*ie7 ff*/	position:absolute;	z-index:21;	background:#999;	height:30px;	width:500px;
}
.foot{	bottom:0 !important;/*ie7 ff*/
}
.main{	height:2000px;
}
</style>
<!--[if IE 6]>
<style type="text/css">
/*ie6 fix顶端元素*/ .head{ top:expression(eval(document.documentElement.scrollTop));
}
/*ie6 fix底端元素*/
.foot{	top: expression(eval((document.compatMode&&document.compatMode=="CSS1Compat")?documentElement.scrollTop+documentElement.clientHeight-this.clientHeight-1:document.body.scrollTop+document.body.clientHeight-this.clientHeight-1));
}
</style>
<![endif]-->

HTML:

<body> <div class="head">	header </div> <div class="main">	<p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p><p>main </p> </div> <div class="foot">	foot </div>
</body>