Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(window).load(function(){
- verticalCenterText( 'article', '.hometitle' );
- });
- jQuery(window).resize(function(){
- verticalCenterText( 'article', '.hometitle' );
- })
- /** CENTER TEXT VERICALLY
- * Center the text element vertically within its containing element
- */
- function verticalCenterText( $containerEl, $textEl ) {
- $=jQuery;
- $( $containerEl ).each(function() {
- if ( $(this).find( $textEl ).length > 0 ) {
- var $containerElHeight = $(this).height();
- var $textElHeight = $(this).find( $textEl ).height();
- $(this).find( $textEl ).css('top', ( $containerElHeight - $textElHeight ) / 2 + 'px');
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement