expression solves the compatibility of fixed positioning under IE6

Source: Internet
Author: User

The technique used in this article is to use an Internet Explorer CSS expression. You cannot use the expression directly, because it may not be updated because it is cached. The simplest way to solve this is to use eval to wrap your statement.

How to solve the problem of "vibration"?

Obviously IE has a multi-step rendering process. When you scroll or resize your browser, it resets all of the content and renders the page again, and then it re-processes the CSS expression. This can cause an ugly "vibrating" bug where the elements in the fixed position need to be adjusted to keep up with your (page) scrolling, so they "bounce".

The trick to solve this problem is to use background-attachment:fixed to add a Background-image:url (About:blank) to the body or HTML element. This forces the page to process the CSS before redrawing. Because the CSS is processed before redrawing, it will also process your CSS expression first before redrawing. This will allow you to achieve a perfectly smooth fixed position element!
CSS code:

/*让修复IE6 position:fixed不可用的Bug! *//* 头部固定 */.fixed-top{position:fixed;bottom:auto;top:0px;}/* 底部固定 */.fixed-bottom{position:fixed;bottom:0px;top:auto;}/* 左侧固定 */.fixed-left{position:fixed;right:auto;left:0px;}/* 右侧固定 */.fixed-right{position:fixed;right:0px;left:auto;}/* 上面的是除了IE6的主流浏览器通用的方法 *//* 修正IE6振动bug */* html, * html body{background-image:url(about:blank);background-attachment:fixed;}/* IE6 头部固定定位 */* html .fixed-top{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));}/* IE6 右侧固定定位 */* html .fixed-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 底部固定定位 */* html .fixed-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 左侧固定定位 */* html .fixed-left{position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft));}

 转载于其他人博客,只用于个人学习

expression solves the compatibility of fixed positioning under IE6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.