Dynamic Menu Resizer


/ Published in: jQuery
Save to your folder(s)

This is a little function that dynamically resizes the navigation, taking into account the size of the item width as well


Copy this code and paste it in your HTML
  1. function resizeMenu($navItem, menuWidth){
  2. var sizeConcat = 0
  3. $navItem.each(function(e){
  4. sizeConcat += $(this).width()
  5. })
  6.  
  7. var widthDif = ((menuWidth-(sizeConcat))/$navItem.length-1)
  8.  
  9. $navItem.each(function(e){
  10. var itemWidth = Math.round(widthDif + $(this).width())
  11. $(this).css({'width': itemWidth +'px'});
  12. })
  13. }

URL: http://jsfiddle.net/bra4C/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.