The CSS fixed value for the position property is extremely useful, particularly in allowing for persistent navigation on long pages. Naturally, versions of IE before 7 don’t support it. I’ve been getting around that using JavaScript.
It’s probably not what the specification states, but a fantastically useful browser method for interpreting CSS would be to simply ignore property values that it doesn’t understand—then, for example, you could have a position: absolute; line followed by a position: fixed; line, and non-compliant browsers (such as IE) would use the former and ignore the latter. Instead, an unrecognized value throws the element(s) affected back to their default positioning (which is presumably static).

There are other methods for fixing this, including one that doesn’t use JavaScript, and this one from Jonathan Snook. They’re full fixes, in that they make IE replicate the position: fixed behavior. My approach is much more lightweight, just using some JavaScript to see if it’s supported and then changing classnames based on that (or, invoking a more complete solution).

It’s rather simple: load the page, create a new element with position: fixed; and top: 0;, then check its offsetTop property. If it’s not 0, then the browser doesn’t support position: fixed and you can work around this as you like.

This entry was posted
on Thursday, March 29th, 2007 at 23:57 29 Mar 2007 and is filed under Blog.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.