Subscribe via RSS

In an ongoing attempt to offer alternative methods to spruce up menus, I’ve pieced together an elastic thumbnail menu.

What does it do exactly?

  • Magnifies menu items when they are hovered over.
  • Menu items expand upwards.
  • View the demo to see it in action.

Hopefully you know what you’re getting into, let’s make this thing happen.


Quick and easy, the general framework we’ll be using goes as follows:

  1. <div id="menuwrapper">
  2. <div id="menu">
  3. <a href="#" class="menuitem"><img src="image.jpg">a>
  4. div>
  5. div>


Normally when a div tag has to expand to accommodate more content, it does so downwards, adding height onto the bottom of the element rather than the top. For this menu we will want to do the exact opposite – when the user hovers over the thumbnail it should expand upward (think about how the OSX dock works).

We’re going to go about this by making use of position:fixed, which essentially lets us “fix” elements to the bottom. Let’s break down the elements.

  1. /* The container which the menu is "locked" to the bottom of */
  2. #menuwrapper{ position:relative; height:210px; }
  3. /* Fixes the whole menu to the bottom of the parent div */
  4. #menu{position:absolute; bottombottom:0;}
  5. /* Each individual menu item fixed to the bottom with display:inline-block to create elasticity */
  6. .menuitem{ position:fixed relative; bottombottom:0px; display:inline-block; }

The jQuery

The jQuery in my example serves two purposes:

  1. Resize images to smaller sizes when page first loads.
  2. Animate images to larger size when hovered over.

Here’s the snippet that makes this all happen (With inline comments for explanations):

  1. $(document).ready(function(){
  2. $('.menuitem img').animate({width: 100}, 0); //Set all menu items to smaller size
  3. $('.menuitem').mouseover(function(){ //When mouse over menu item
  4. gridimage = $(this).find('img'); //Define target as a variable
  5. gridimage.stop().animate({width: 200}, 150); //Animate image expanding to original size
  6. }).mouseout(function(){ //When mouse no longer over menu item
  7. gridimage.stop().animate({width: 100}, 150); //Animate image back to smaller size
  8. });
  9. });

Internet Explorer Image Scaling Fix

This has been brought to attention before, but when it comes to resizing images, Internet Explorer won’t do a good job unless you add the follow line into your css:

img { -ms-interpolation-mode: bicubic; }

After taking care of that fix, your menu is ready to roll, nicely done.

Live Demo :

Download :

Posted by ABDUL SABOOR Monday, October 5, 2009


Post a Comment