molendijk
05-23-2008, 01:01 AM
1) CODE TITLE: Fixed position crossbrowser: addition
2) AUTHOR NAME/NOTES: Arie Molendijk
3) DESCRIPTION: Emulating 'position: fixed' in IE with IE-expressions that are inherently mode-independent.
4) INFO: After writing these pages (http://www.dynamicdrive.com/forums/showthread.php?t=31661&highlight=molendijk) on emulating 'position: fixed' in IE I found a method for fixing elements (with the help of IE-expressions) that does not require checking the mode (quirks or standard) of the page. It must be preferred to what I proposed on the above link, because it's simpler. Both document.body and document.documentElement can indeed be replaced with offsetParent.
Css:
.X (for class) or #X (for unique ID) {
position: absolute;
top: expression(offsetParent.scrollTop + some_value_1 + 'px');
left: expression(offsetParent.scrollLeft + some_value_2 + 'px');
}
If we want the element to be fixed at the bottom of the page, for instance, we write:
top: expression(offsetParent.scrollTop -3 + (offsetParent.clientHeight-this.clientHeight) +'px' );
(The small negative number is needed to avoid endless scrolling).
---
Arie Molendijk
2) AUTHOR NAME/NOTES: Arie Molendijk
3) DESCRIPTION: Emulating 'position: fixed' in IE with IE-expressions that are inherently mode-independent.
4) INFO: After writing these pages (http://www.dynamicdrive.com/forums/showthread.php?t=31661&highlight=molendijk) on emulating 'position: fixed' in IE I found a method for fixing elements (with the help of IE-expressions) that does not require checking the mode (quirks or standard) of the page. It must be preferred to what I proposed on the above link, because it's simpler. Both document.body and document.documentElement can indeed be replaced with offsetParent.
Css:
.X (for class) or #X (for unique ID) {
position: absolute;
top: expression(offsetParent.scrollTop + some_value_1 + 'px');
left: expression(offsetParent.scrollLeft + some_value_2 + 'px');
}
If we want the element to be fixed at the bottom of the page, for instance, we write:
top: expression(offsetParent.scrollTop -3 + (offsetParent.clientHeight-this.clientHeight) +'px' );
(The small negative number is needed to avoid endless scrolling).
---
Arie Molendijk