General position: fixed; implementation method
Take my blog as an example. The CSS code used by the <div id = "top">... </div> HTML element in the lower right corner is as follows:
The code is as follows: |
Copy code |
# Top { Position: fixed; Bottom: 0; Right: 20px; } |
To fix the <div id = "top">... </div> element at the bottom of the browser and 20 pixels to the right.
How to implement position: fixed; in IE6
As mentioned earlier, position: fixed; cannot be used directly in IE6 ;. You need some CSS Hack to solve it. Of course, IE6 is not just about position: fixed;
Let <div id = "top">... </div> fix the elements at the bottom of the browser and 20 pixels to the right.
Later I found a piece of code, which is compatible with ie6 and fixed at the bottom.
The code is as follows: |
Copy code |
* Body { Background-attachment: fixed; Background-image: url (about: blank);/* required, anti-jitter */ } * Body # fixed { Position: absolute; Top: expression(eval(document.doc umentElement. scrollTop + 10);/* top fixed suspension */ /* Top: expression(eval(document.documentelement.scrolltop?document.doc umentElement. ClientHeight-this.offsetHeight-10);/* bottom fixed suspension */ } # Fixed { Border: 1px solid; Position: fixed; Right: 10px; Top: 10px; } |
Flash Problems
The problem has not been completely solved yet. After using the above method, you will find that the fixed positioning elements will flash when rolling the scroll bar. To solve the flash problem, add the following content to the CSS file:
The code is as follows: |
Copy code |
* Html { Background-image: url (about: blank ); Background-attachment: fixed; } |
* Is identified for IE6.
At this point, the position: fixed; problem of IE6 has been resolved.