Andrey Shitov
True |
Task: |
to show what it takes to emulate the position: fixed CSS-property.
| ||
Stylesheet code that allows fixing an element on the page is a known thing. Our technologists use different techniques whichever one they fancy the most.
top: expression(document.body.scrollTop + "px"); But this elementary code doesnt work, so here are three other ways:
top: expression( eval(document.body.scrollTop) + "px" );
top: expression( document.getElementsByTagName("body")[0].scrollTop + "px" );
top: expression( parseInt(document.body.scrollTop, 10) + "px" ); | See Vladimir Tokmakovs article Fixed positioning in IE |
This block is fixed when you scroll up/down and
in MSIE.
Roma Voronezhsky and Yura Vasilchikov have come up with a strikingly simple solutionyou can avoid jitter by fixing the page background: body { background: url('/n.gif') no-repeat; background-attachment: fixed; } File n.gif is a one-pixel transparent image (and you dont even have to upload it to server). This approach works well for all browsers starting from MSIE 5. Note: Keep in mind that for MSIE 7 there is a better way to deal with |