Click to See Complete Forum and Search --> : fixed divs


cnh
09-14-2004, 11:12 AM
I'm sure this has been asked many times, but:

how you do fix a div so that it doesn't scroll with the rest of the page (and everything else scrolls underneath it)?

Many thanks, Nicholas Hill

Jona
09-14-2004, 11:23 AM
#myDIV {
position: fixed;
top: 50px;
left:50px;
}


Note that it doesn't work in Internet Explorer.

cnh
09-14-2004, 12:16 PM
Thank you. No wonder I couldn't get it to work ...

Jona
09-14-2004, 01:51 PM
You're welcome. If you're using a proprietary markup translator (http://www.microsoft.com/ie), I'd suggest you get a real browser (http://www.mozilla.org/firefox/) and browse happy (http://www.browsehappy.com/). ;)

cnh
09-15-2004, 04:39 AM
I could use an alternative; the snag is that over 90% of my site visitors use IE. Therefore I code for IE since my vistors use it.

baconbutty
09-15-2004, 05:03 AM
Depends on what you are trying to achieve.

I don't think in IE that you can hold a div in a fixed position with respect to the client window (as opposed to the BODY element) without some javascript.

If you have some content that users will scroll through, then you could look at putting that content in a separate IFRAME or a separate DIV that has overflow:auto set, so that BODY does not scroll.

Jona
09-15-2004, 05:12 AM
Baconbutty is right. You could use JavaScript, but should not require it; is it 100% necessary that the DIV float over the rest of the page, or do you just "need" it to? If it's not required for any reason, JavaScript may be a practical solution.

cnh
09-15-2004, 07:47 AM
many thanks for yr replies- it's not 100% necessary, but thought it wd be nice to try - then found it didn't work ...

Jona
09-15-2004, 07:56 AM
I'd apologize, but Internet Explorer is at fault here.