positioning div relative to window

L

libsfan01

hi

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

regards

marc
 
D

David Dorward

libsfan01 said:
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.
 
T

totalstranger

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.
 
R

Randy Webb

totalstranger said the following on 8/28/2006 5:57 PM:
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.
 
T

totalstranger

totalstranger said the following on 8/28/2006 5:57 PM:

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="stylesheet" TYPE="text/css" HREF="CSS/Default.css"
<!--[if lte IE 6]>
<LINK REL="stylesheet" TYPE="text/css" HREF="CSS/IE5.css">
<![endif]-->
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top