Stick Element To The Bottom Of Its Container - Sticky-Element

Stick Element To The Bottom Of Its Container - Sticky-Element
File Size: 4.04 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Sticky-Element is a really simple jQuery plugin which makes any element sticky at the bottom of its parent container as you scroll down/up the webpage. Based on CSS 'position: fixed' property.

How to use it:

1. Create an element that will be stuck at the bottom of your sidebar.

<div class="sidebar" id="sidebar">
  <div class="text">
    <div>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </div>
    <div>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </div>
    <div>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </div>
  </div>
  <div id="element" class="element">
    Sticky Element
  </div>
</div>

2. Include jQuery JavaScript library and the jQuery Sticky-Element plugin's script at the bottom of the html page.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.sticky.js"></script>

3. Add the following CSS snippets to your web page. Done.

.sticky{
  position: fixed;
  bottom: 0;
  left: auto;
  width: 200px;
}

This awesome jQuery plugin is developed by alexmicic. For more Advanced Usages, please check the demo page or visit the official website.