Skip to content

Commit 463992c

Browse files
committed
Initial commit
0 parents  commit 463992c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

README

Whitespace-only changes.

jquery.flexverticalcenter.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*global jQuery */
2+
/*!
3+
* FlexVerticalCenter.js 1.0
4+
*
5+
* Copyright 2011, Paul Sprangers http://paulsprangers.com
6+
* Released under the WTFPL license
7+
* http://sam.zoy.org/wtfpl/
8+
*
9+
* Date: Fri Oct 28 19:12:00 2011 +0100
10+
*/
11+
(function( $ ){
12+
13+
$.fn.flexVerticalCenter = function( onAttribute ) {
14+
15+
return this.each(function(){
16+
var $this = $(this); // store the object
17+
var attribute = onAttribute || 'margin-top'; // the attribute to put the calculated value on
18+
19+
// resize to box the maintain the set ratio
20+
var resizer = function () {
21+
// get parent height minus own height and devide by 2
22+
$this.css(
23+
attribute, ( ( $this.parent().height() - $this.height() ) / 2 )
24+
);
25+
};
26+
27+
// Call once to set.
28+
resizer();
29+
30+
// Call on resize. Opera debounces their resize by default.
31+
$(window).resize(resizer);
32+
33+
});
34+
35+
};
36+
37+
})( jQuery );

0 commit comments

Comments
 (0)