Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created July 29, 2009 16:17
Show Gist options
  • Save subtleGradient/158243 to your computer and use it in GitHub Desktop.
Save subtleGradient/158243 to your computer and use it in GitHub Desktop.
Make position:fixed work in IE6
/*Make position:fixed work in IE6!*/
.fixed-top /* position fixed Top */{position:fixed;bottom:auto;top:0;}
.fixed-bottom /* position fixed Bottom */{position:fixed;bottom:0;top:auto;}
.fixed-left /* position fixed Left */{position:fixed;right:auto;left:0;}
.fixed-right /* position fixed right */{position:fixed;right:0;left:auto;}
* html,* html body /* IE6 Fixed Position Jitter Fix */{background-image:url(about:blank);background-attachment:fixed;}
* html .fixed-top /* IE6 position fixed Top */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));}
* html .fixed-right /* IE6 position 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));}
* html .fixed-bottom /* IE6 position 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)));}
* html .fixed-left /* IE6 position fixed Left */{position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft));}
@zhuzhuaicoding
Copy link

nice work

@nrone
Copy link

nrone commented Jan 29, 2014

Nice work :-)

http://msdn.microsoft.com/en-us/library/ie/dn384050(v=vs.85).aspx
unfortunately IE screwed us.

@heyiyang
Copy link

谢谢 and thanks :-)

@arsenik
Copy link

arsenik commented Oct 20, 2014

document.documentElement.clientHeight may not exists use document.body.clientHeight instead.

document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment