Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Nov 2010
    Location
    London
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Animating CSS ul navigation with jQuery

    Hi all,

    I'm currently in the process of designing a site for a friend of mine but wanted to add a little bit of animation to the main navigation bar to make it all look a bit more polished! My knowledge of coding is very limited so I am finding it quite difficult achieving the effect I'm after!

    I currently have the nav bar set up in it's own div tag and have created the usual ul style of navigation and then used the CSS background position property to position the nav bar sprite for a basic roll-over effect. What I'm after though is a smooth transition from the normal button state to the hover state so it looks like the hover state is slowly fading in.

    After searching around on Google I have quickly learnt that I will need to add jQuery to my site to achieve this effect. This is fine but I have yet to find a tutorial that teaches me how to get the specific effect I'm after!

    If possible could someone explain (in laymans terms) how I go about adding jQuery to the nav bar so it fades between the two states instead of snapping from one part of the sprite to the other? Alternatively, if anyone knows of a good tutorial on how to do this could you point me in the right direction?

    I've attached the sprite I'm working with below so you can see the normal and hover states.

    Thanks in advance
    Rosedani
    Attached Images Attached Images

  2. #2
    Member
    Join Date
    Oct 2009
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    Not sure if you still need this but here's what you're looking for:

    Code:
    $(function() {
    	
    // set opacity to nill on page load
    $("#menuID ul span").css("opacity","0");
    
    // on mouse over
    $("#menuID ul span").hover(function () {
    // animate opacity to full
    $(this).stop().animate({
    opacity: 1
    }, 'slow');
    },
    // on mouse out
    function () {
    // animate opacity to nill
    $(this).stop().animate({
    opacity: 0
    }, 'slow');
    });
    
    });
    You need to set your menu items up like this, and the background image needs to be defined in CSS:

    HTML Code:
          <li><a href="#" class="uniqueClass"><span></span></a></li>
    I have a working example here if you wish to look further into the code....

    Our Locations | Find a Dealership | Vertu Motors PLC

    Rachel
    Find me on twitter | @rachelgregory84

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Location
    North of Scotland
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am sure you can do this affect using CSS3.

    Just coming to the end of my lunch break at work so I'm afraid I can't give you a bit more guidance.

    Just look up CSS3 Transition fade

Similar Threads

  1. Navigation Bar
    By Smuj56 in forum Website Design Forum:
    Replies: 11
    Last Post: 04-24-2011, 08:58 AM
  2. Fancy Countdown – jQuery plugin
    By fergsi in forum Website Design Resources:
    Replies: 0
    Last Post: 03-12-2011, 12:15 AM
  3. PHP Navigation problems
    By Royale-Graphics in forum Website Coding & Programming Forum:
    Replies: 2
    Last Post: 10-28-2009, 10:39 AM
  4. Updated website with navigation!
    By designer01 in forum Website Design Critique:
    Replies: 7
    Last Post: 05-12-2009, 08:35 AM
  5. Slimbox navigation keys
    By MarkS in forum Website Coding & Programming Forum:
    Replies: 2
    Last Post: 02-16-2009, 09:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •