Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Dynamically center text in Jquery

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30544
    Awkward_Todd
    Participant

    This refers to screencast #79: Complete/Non-Queuing Animations with jQuery. I am trying to make a navigation bar out of this but can’t seem to find a way to dynamically center the text in the div where the div grows in height.

    Here’s the code (solution by Liam Goodacre)

    // on ready
    $(function() {
    // setup
    $(‘.navtop’).hover(function() {
    $e = $(this); // this cache
    // dequeue, stop, then animate height
    $e.dequeue().stop().animate({
    height: ’35px’
    });
    }, function() {
    $e = $(this); // this cache
    $e.animate({ // animate height
    height: ’25px’
    });
    });
    });

    Any help would be great! Thank you.

    #78134
    Damion
    Member

    Try using

    $e.dequeue().stop().animate({
    height: ’35px’,
    line-height: ’35px’
    });

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.