🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

Just another jQuery centering plugin that makes you responsive element always stay centered even when you resize the browser window.

centering

Documentation

centerThis.js

a simple jQuery plugin to Center an element to its parent, or the browser, a super simple demo can be found here.

$("element").centerThis({   browser: false, // center to the browser or the parent element   offsetTop: 0, // offset the math of the center   destructive: false // true will switch to using padding, not left and top positions });

How it works:

By grabbing the elements height and width, along with its parents; centerThis.js does some pretty simple math to calculate its center position... and sets the element there, setting it to position: absolute in the process.


You May Also Like