jQuery Plugin To Centralize DOM Elements In Parent Container - center.js

File Size: 8.16 KB
Views Total: 547
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Centralize DOM Elements In Parent Container - center.js

Just another jQuery 'center align' plugin used to vertically and/or horizontally centralize an HTML DOM element in its parent container. The plugin works on any responsive web layout so the DOM element will always stay centered even when you resize the browser window.

Basic usage:

1. Be sure you have jQuery library and the jQuery center.js script included in the html page.

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

2. Center a single element around its parent.

<div class="center" data-center data-box>
  <div data-center data-box>
     Vertical and Horizontal center alignment
  </div>
</div>

3. Center multiple elements vertically

<div class="mvcenter" data-box>
  <div data-mvcenter data-box>
    Element 1
  </div>
  <div data-mvcenter data-box>
    Element 2
  </div>
  <div data-mvcenter data-box>
    Element 3
  </div>
</div>

4. All Html5 data attributes.

  • data-center: center a single element vertically and horizontally
  • data-vcenter: center a single element vertically
  • data-hcenter: center a single element hotizontally
  • data-mvcenter: center multiple elements vertically
  • data-mhcenter: center multiple elements horizontally

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