ie6下使用css中的动态函数或js定时器实现漂浮功能时会有闪烁现象,下面这个方法纯粹使用css,可以完美解决此问题。
- < div id = "floatbody" style = "z-index:999;position:fixed;bottom:0;left:0;_position:absolute;_top:expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight);overflow:visible;height:43px;width:100%;text-align:center;" > div >
上面代码已经可以满足普通需求,唯一缺陷就是在ie6下随着滚动条滚动时该div块会随之闪动,不像firefox下表现的那般稳如泰山。要解决该问题,还需要补充2点:
1:页首的规范声明应如下:(针对ie6)
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2.为body的style属性添加如下内容:
- background-image : url (anyname.jpg); background-attachment : fixed ;
(第二点中的背景图片可以随意填写,不需要真实图片路径)
本文系个人原创,更多细节详见我的博客:http://richard.cnlife.org/