WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Don't wan't the div to scroll with page, Joakim Ljung, July 23, 2003
     Re:Don't wan't the div to scroll with page, Chris, July 25, 2003
         Re:Don't wan't the div to scroll with page, Chris, July 25, 2003
             Re:Don't wan't the div to scroll with page, Erik Arvidsson, July 26, 2003

Subject: Re:Don't wan't the div to scroll with page From: Erik Arvidsson Date: July 26, 2003
position: fixed is supported by /all/ browsers except IE for Windows :'(

For IE it is better to use a container with overflow auto that contains the main page content and then place your fixed element outside that container.

erik

__________________________________________________

I should expand on that, incase you think i mean position: absolute and nothing else.
Basically, give the div an absolute position, and then catch the onscroll event and set the position to the original top position plus the body's scrollTop.

function keepInPosition() {
document.getElementById("sticky").style.top = document.body.scrollTop + 20 + "px";
}
document.body.onscroll = keepInPosition;
...

<div id="sticky" style="position: absolute; top: 20px; left: 20px">I should stay still</div>

Or, of course, you could give it position: fixed and no javascript is required :)
Is that supported in MSIE? Don't know about it's CSS support...

And I'm not sure if smooth scrolling will make the above script not work, I think i read it causes problems...

Should've went straight away with position: fixed... ah well...
Chris

From: Joakim Ljung
Sent: July 23, 2003
Subject: Re:Don't wan't the div to scroll with page

In the dockbar example on web-fx the div does not scroll with the page, how do i acomplish that?








Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX