Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielbull/jquery-centeralign
Vertical or Horizontal Align an object
https://github.com/gabrielbull/jquery-centeralign
Last synced: 4 days ago
JSON representation
Vertical or Horizontal Align an object
- Host: GitHub
- URL: https://github.com/gabrielbull/jquery-centeralign
- Owner: gabrielbull
- License: gpl-2.0
- Created: 2012-03-09T17:50:00.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-04-30T18:29:16.000Z (over 12 years ago)
- Last Synced: 2024-10-11T15:18:40.292Z (28 days ago)
- Language: JavaScript
- Homepage:
- Size: 94.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE-GPL.txt
Awesome Lists containing this project
README
# jQuery Center Align
Align an element to the center of the screen.
## Example Usage
```javascript
$('#element').centeralign();
```You can specify if whether you want the horizontal or the vertical alignment, like in this example:
```javascript
$('#element').centeralign({'vertical': false});
```
```javascript
$('#element').centeralign({'horizontal': false});
```## Use it with flexbox and Modernizr
Vertical alignment has become a child's game with the introduction of flexbox. Unfortunatly, not all modern browsers support flexbox yet. If you are using Modernizr you can detect wheter or not the browser supports flexbox and load jQuery.centerAlign only if it doesn't. For this, consider this example:
```javascript
Modernizr.load([
{
test : Modernizr.flexbox,
nope : 'js/libs/jquery.centeralign.min.js',
complete : function () {
if(!Modernizr.flexbox) {
$("#box").centeralign();
}
}
}
]);
```