how to make sidebar?

How do you make a sidebar stick?

  • Two example websites of what I am referring to is "Cognition" ( http://cognition.happycog.com/article/wish-upon-a-star ) The "previous button" will scroll with the page until it reaches the top then it will stick and stay at the top of the page. Another website doing this is http://www.fastcodesign.com/ Does anyone know if there is a tutorial on how to do this?

  • Answer:

    There are two general approaches: CSS or JavaScript. CSS uses position fixed, which will make the element stay in the same spot regardless of page scrolling. The method on Congition can be done with a simple jQuery plug-in. There are quite a few out there. Just google "jquery sticky sidebar" and you'll find the plug-in and tutorials.

Todd Zaki Warfel at Quora Visit the source

Was this solution helpful to you?

Other answers

The recipe I have used includes marking up your site with a side bar or <aside> ;) with relative positioning. Then when that element reaches a certain point (page scroll), javascript will set the css attribute to absolute positioning and presto the container sticks. Look for this behavior when shopping for a plugin.  What is nice about your first example is that it also slaps the #next-page/#prev-page control to the bottom for little screens... One Web!

Ken Whaler

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.