By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,814 Members | 2,162 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,814 IT Pros & Developers. It's quick & easy.

positioning div relative to window

P: n/a
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

Aug 28 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Aug 28 '06 #2

P: n/a
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.
Aug 28 '06 #3

P: n/a
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 28 '06 #4

P: n/a
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="stylesheet" TYPE="text/css" HREF="CSS/Default.css"
<!--[if lte IE 6]>
<LINK REL="stylesheet" TYPE="text/css" HREF="CSS/IE5.css">
<![endif]-->
Aug 29 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.