Re: positioning div relative to window



On or about 8/28/2006 7:08 PM, it came to pass that Randy Webb wrote:
totalstranger said the following on 8/28/2006 5:57 PM:
On or about 8/28/2006 3:58 PM, it came to pass that David Dorward wrote:
libsfan01 wrote:

is it possible to position a div relative to the document window? so
for example if the page is scrolled down the div in question does not
move

position: fixed.
Not supported by MSIE.
JavaScript hacks to simulate it in that browser are available. Google can
help you find them.

Fixed elements are supported by IE7 in strict mode, it acts like IE6 in quirks mode. I use the Fixed element simulator with one of my pages, and while it does work I feel it's kind of ugly.

Then use position:fixed in IE7 and let IE6 users migrate.

Or, something like this:

<div style="top:0px;left:0px">Top Div</div>
<div style="top:20px;left:0px;overflow:scroll">Put your page contents here</div>

And let them scroll the div element instead of the body.

You can use IE's proprietary conditional comments to select the proper CSS and make settings based upon the version of IE that's executing. The comments are not processed by other browsers. I implemented this when I wanted to get rid of my javascript sniff routine. This lets my site work for most modern browsers.

A sample of what I use on my site follows. If it's IE6/5 the IE5.css will cascade and override the Default.css.

<LINK REL="style***" TYPE="text/css" HREF="CSS/Default.css"
<!--[if lte IE 6]>
<LINK REL="style***" TYPE="text/css" HREF="CSS/IE5.css">
<![endif]-->
.


Loading