Surely there has been a instance when you are creating an application that has a sidebar and a main content div. In the case of content being too long, the useful sidebar info can get left behind when you scroll down to see the other content. In that case, you need to have some solution to scroll the sidebar content down as the user scrolls down. You can go with something like:
And that will work, if the sidebar content is fixed to the top of the page. If not, you need something to know when to stick the content to the top of the page and when to unstick it, as the users srolls up.
For this to work, your #sticky div must be nested inside another one in the sidebar, let’s call it #sidebar so it wont pop out to the left while you scroll down.
Resources: Sticky div jsfiddle</a>