0

For example...the new facebook activity stream on the right. Or on okay cupid (the message/rating dialogue).

How does this work exactly. Can someone point me to a tutorial or explanation?

Thanks!

2 Answers 2

4

There are many ways to do this but here is one using CSS only

<div style="position:fixed; left:0; top:0; height:100px; width:100%">Stuck to Top</div> 

Here is a fiddle

http://jsfiddle.net/2kmQe/

Sign up to request clarification or add additional context in comments.

2 Comments

hmm, this seems to be basically fixed positioning. I want it so that the element is placed in the page normally, and only "sticks" to the top when you scroll past it, if that makes sense.
@weckersham ... sorry about that but you may want to repost the new details to your question for others to see and assist with.
2

Add some Javascript to set position: fixed; top: 0px; when $(window).scrollTop() reaches the $("#element_id").offset().top.

Google does a similar thing with their new gmail look

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.