DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Web marketing expert & entusiest web designer Sagive has posted 2 posts at DZone. You can read more from them at their website. View Full User Profile

Easy Auto Menu Items width

06.21.2013
| 3541 views |
  • submit to reddit
jQuery(function($){
    var itemscount = $("#top-menu li").size();
    var percentage = 100 / itemscount;
     
    $("#top-menu > li").css('width', percentage+'%');
});

The following snippet helps us by changing the width of each item in a menu / list automaticlly by grabbing the number of items and dividing them by 100%....

Used it inseveral projects and it works gr8 and easy to integrate.

Enjoy...