在线预约 | 微信营销平台 | 自助平台 | 手机客户端 | 设为首页 | 加入收藏
众旺互联做您身边的网络专家
咨询热线(免长途费):
石家庄网站建设电话
当前位置:首页 -> 新闻中心 -> 建站知识 -> 正文

解决IE6不支持position:fixed的问题

发布日期:2013-04-29  信息来源:众旺互联  点击:
分享:
  前段时间因为公司的某个项目需要用到底部固定元素在网页中随着浏览器滚动而滚动,当然用position:fixed这个属性来做,可是问题来了,IE6.0下面不支持position:fixed这个属性。 在网上查找资料,实践,最终OK了, 石家庄网站建设 贴出来大家分享。 当然,在IE
  前段时间因为公司的某个项目需要用到底部固定元素在网页中随着浏览器滚动而滚动,当然用position:fixed这个属性来做,可是问题来了,IE6.0下面不支持position:fixed这个属性。
 
  在网上查找资料,实践,*终OK了,石家庄网站建设贴出来大家分享。
 
  当然,在IE6以上版本,火狐,谷歌等浏览器都是件容易的事情,直接用position:fixed这个属性就可以搞定。如:

.top {position:fixed;bottom:auto;top:0px;} /* 头部固定 */
.bottom {position:fixed;bottom:0px;top:auto;} /* 底部固定 */
.left {position:fixed;right:auto;left:0px;} /* 左侧固定 */
.right{position:fixed;right:0px;left:auto;} /* 右侧固定 */

  但在IE6及以下版本这样设置是没用的,要设置成这样:

body{background-image:url(about:blank);background-attachment:fixed;} /* 修正IE6振动bug */
.top {position:absolute;bottom:auto;top:expression(evaldocument.documentElement.scrollTop));} /* IE6 头部固定*/
.left{position:absolute;left:auto;right:expression(evaldocument.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));} /* IE6 右侧固定 */
.right {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));} /* IE6 右侧固定 */
.bottom {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)));} /* IE6 底部固定 */
售前咨询

4008887704

售后服务

0311-87222545

在线咨询

工作日9:00-18:00 点击进入

预约专家

提供专业解决方案 点击进入

访问微博

唯一官方微博平台 点击进入

联系我们 | 公司简介 | 付款方式 | 招贤纳士 | 产品导航 | 在线预约 | 网站地图

版权所有 2010-2030 石家庄众捷网络科技有限公司 冀ICP备11028497号-1冀ICP备11028497号-3
咨询热线:400-888-7704 咨询信箱:kefu@zw0311.com