Advertisement
Guest User

text-in-circles.js

a guest
Aug 11th, 2013
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(window).load(function(){
  2.         verticalCenterText( 'article', '.hometitle' );
  3. });
  4.  
  5. jQuery(window).resize(function(){
  6.         verticalCenterText( 'article', '.hometitle' );
  7. })
  8.  
  9. /** CENTER TEXT VERICALLY
  10.  * Center the text element vertically within its containing element
  11.  */
  12. function verticalCenterText( $containerEl, $textEl ) {
  13.  
  14.         $=jQuery;
  15.  
  16.         $( $containerEl ).each(function() {
  17.  
  18.                 if ( $(this).find( $textEl ).length > 0 ) {
  19.  
  20.                         var $containerElHeight = $(this).height();
  21.                         var $textElHeight  = $(this).find( $textEl ).height();
  22.  
  23.                         $(this).find( $textEl ).css('top', ( $containerElHeight - $textElHeight ) / 2 + 'px');
  24.  
  25.                 }
  26.  
  27.         });
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement