How to make a div sticky?

How to make a div sticky or float it within header and footer or within a parent item.

Sometime we need a div in sidebar to float within header and footer, in this requirement you can write your own code and in jQuery or JavaScript but if you wish to use any third party library then I would suggest you to use the below one which is really very easy and light weight to use. You can just need to include the library and put a snippet of code where you want that floating feature and you will see that magic happening. On scroll of the window you will can the div floating in between of the header and footer. You will just need to mention the parent item you want the div floating within. Please refer to below example:

Download Js library:

Code snippet:


For more options you can refer to the below link and get a detailed information with multiple example to use the same.