user1187135
user1187135

Reputation:

How to switch fixed elements when scrolling down the page

How do people switch fixed elements when scrolling down the page? Here's a perfect example of what I mean at www.Joel.is. If you look at the share buttons, as you scroll down past one post, the share button of the next post replaces the previous one using position:fixed

I have only seen posts that answer how to create the initial fixed position, but not switching. (http://stackoverflow.com/questions/4907872/changing-an-elements-css-position-after-scrolling-down-the-page).

Upvotes: 1

Views: 516

Answers (1)

c..
c..

Reputation: 1054

You would use the same principles, but edit the style of the element.

<div style="position: static;" id="ele"></div>

and then:

document.getElementById('ele').style.position = "absolute";

or for jQuery:

$('#ele').css('position', 'absolute');

Upvotes: 2

Related Questions