Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.fn.fullCenter = function() {
- return this.each(function() {
- var $el = $(this);
- $.fn.fullCenter.center($el);
- })
- }
- $.fn.fullCenter.center = function($el) {
- console.log($el);
- console.log("$el.outerHeight(): " + $el.outerHeight());
- console.log("$el.outerWidth(): " + $el.outerWidth());
- console.log("$el[0].scrollHeight: " + $el[0].scrollHeight);
- // Change the margin-top and margin-left
- if($el.data('center')) {
- var params = $el.data('center').split(" ");
- if(params.indexOf('vertical') != -1) {
- $el.css({
- 'margin-top': '-' + ($el.outerHeight() / 2) + 'px'
- })
- }
- if(params.indexOf('horizontal') != -1) {
- $el.css({
- 'margin-left': '-' + ($el.outerWidth() / 2) + 'px'
- })
- }
- } else {
- $el.css({
- 'margin-left': '-' + ($el.outerWidth() / 2) + 'px',
- 'margin-top': '-' + ($el.outerHeight() / 2) + 'px'
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment