visit the blog of Thomas aylott, a core member of mootools. However, it seems that the title is a bit outdated, and the actual effect is not so good. It defines four categories, which are used to fix the top, bottom, and left of the view respectively. Unfortunately, it cannot solve the problem of using top, bottom, left, right (see the example ). It uses the obsolete expression of IE8 to calculate the page size, so as to fix the elements we want to fix. One technique is used to add a background image to the HTML or body element and Set background-Attachment: fixed to force CSS execution before page re-painting, that is, execute the expression in it. In addition, we do not need a real image. We can just give it an about: blank command, just like dealing with links at ordinary times, the only difference is that a hover effect must be provided with an href.
. 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;} * HTML, * html body {background-image: URL (about: blank); background-Attachment: fixed;} * HTML. fixed-top {position: absolute; bottom: auto; top: expression(eval(document.doc umentelement. scrolltop);} * HTML. fixed-right {position: absolute; Right: auto; left: expression(eval(document.documentelement.scrollleft?document.doc umentelement. clientWidth-this.offsetWidth-(parseint (this. currentstyle. marginleft, 10) | 0)-(parseint (this. currentstyle. marginright, 10) | 0);} * HTML. fixed-bottom {position: absolute; bottom: auto; top: expression(eval(document.documentelement.scrolltopdeskdocument.doc umentelement. clientHeight-this.offsetHeight-(parseint (this. currentstyle. margintop, 10) | 0)-(parseint (this. currentstyle. marginbottom, 10) | 0);} * HTML. fixed-left {position: absolute; Right: auto; left: expression(eval(document.doc umentelement. scrollleft ));}
<Br/> <! Doctype HTML> <br/> <HTML dir = "LTR" lang = "ZH-CN"> <br/> <pead> <br/> <meta charset = "UTF-8" /> <br/> <title> CSS position fixed for IE6 </title> <br/> <style> <br/>. fixed-top {position: fixed; bottom: auto; top: 0px ;}< br/>. fixed-bottom {position: fixed; bottom: 0px; top: auto ;}< br/>. fixed-left {position: fixed; Right: auto; left: 0px ;}< br/>. fixed-right {position: fixed; Right: 0px; left: auto ;}</P> <p> * HTML, * html body {background-image: URL (about: blank); background-Attachment: Fixed ;}< br/> * HTML. fixed-top {position: absolute; bottom: auto; top: expression(eval(document.doc umentelement. scrolltop) ;}< br/> * HTML. fixed-right {position: absolute; Right: auto; left: expression(eval(document.documentelement.scrollleft?document.doc umentelement. clientWidth-this.offsetWidth-(parseint (this. currentstyle. marginleft, 10) | 0)-(parseint (this. currentstyle. marginright, 10) | 0);} <br/> * HTML. fixed-bottom {position: absolute; bottom: auto; top: expression(eval(document.documentelement.scrolltopdeskdocument.doc umentelement. clientHeight-this.offsetHeight-(parseint (this. currentstyle. margintop, 10) | 0)-(parseint (this. currentstyle. marginbottom, 10) | 0) ;}< br/> * HTML. fixed-left {position: absolute; Right: auto; left: expression(eval(document.doc umentelement. scrollleft) ;}< br/>. fixed-bottom {<br/> position: fixed; <br/> bottom: 20px; <br/> Background: Aqua; <br/> width: 200px; <br/> Height: 200px; <br/>}< br/> </style> </P> <p> </pead> <br/> <body> <br/> <Div class =" fixed-bottom "> </div> </P> <p> </PRE> <br/> </body> <br/> </ptml> <br/>
RunCode
PS: To really solve this IE6 bug, we need to use Dean Edwards's ie7.js