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

CSS样式表
shtml精简教程让你知道什么是shtml
很不错的 CSS Hack 又学了一招
Default style sheet for HTML 4
资料:Unicode 汉字内码对应表
解决CSS中 display 与 visibility 的区别
制作WEB在线编辑器-插入HTML标签
编写纯 CSS 弹出菜单的原理及实现 By shawl.qiu
关于《精通css》之几个不错的注意事项
position:relative/absolute无法冲破的等级
CSS样式表常用小技巧收藏
收集的web页面html中常用的特殊符号大全
bc1998录制的css视频教程推荐新手看下
dl+ol应用分析
li的简单应用
web打印的另类方法
用CSS实现的一张图完成的按钮效果
文章内容页广告浮于左上角的解决办法
广告放在文章页左上角的解决办法二
iframe的使用用法
FIF互动帮助手册系列-HTML手册 flash版

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 128 ::
收藏到网摘: 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>