Skip to content

DanielTamkin/centerThis.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

jQuery plugin to center an element in its parent.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published