Drunkk Hero
Drunkk Hero

Reputation: 3

Fixed scrolling object (CSS)

I wanted to ask a question, the thing is that I know a little CSS and a little bit of jQuery. What I'm trying to do is put a FB like button on my page, when the viewer scrolls the page and the button reaches the top, it should be fixed at the top as the viewer scrolls and if the viewer scrolls back up, it should return to its original position. I've tried position:fixed; and position:absolute; but they don't work as expected. I read somewhere that I will have to use javascript to achieve this but can I do it with CSS + jQuery because those are what I can understand easily. Please visit this link: http://bit.ly/19INM0r and look at the like and twitter button on the left and how they react when you scroll, that's what I want to do.

Upvotes: 0

Views: 405

Answers (2)

André Dion
André Dion

Reputation: 21708

position: sticky; is what you're after. Here's an overview on the new feature that includes a backwards compatible solution.

Upvotes: 0

Vinícius Moraes
Vinícius Moraes

Reputation: 3516

Here is a good plugin to do what you wan't http://stickyjs.com/

Upvotes: 2

Related Questions