Cross-Platform jQuery Plugin To Stick Objects To Top - fixer.js

File Size: 6.02 KB
Views Total: 690
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Cross-Platform jQuery Plugin To Stick Objects To Top - fixer.js

fixer.js is a lightweight jQuery plugin that provides a super easy way to make an element sticky at the top of the window, but relative to its parent container.

How to use it:

1. Assume you want to position an element "side" relative to its parent element "content".

<div class="content">
  <div class="side"></div>
  <div class="main"></div>
</div>

2. Make the parent element 'position: relative'.

.content {
  position: relative;
  ...
}

3. Include the jQuery library and the jQuery fixer.js plugin at the bottom of the web page.

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="jquery.fixer.js"></script>

4. Call the plugin on the element to position it fixed relative to its parent container.

$('.side').fixer();

5. Default plugin options.

$('.side').fixer({

  // distance in pixels
  gap: 0,

  // horizontal mode
  horizontal: false,

  // callback function
  isFixed: $.noop

});

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