Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Created October 10, 2011 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisguitarguy/1274465 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/1274465 to your computer and use it in GitHub Desktop.
Dynamically adjust menu padding with jQuery
jQuery(document).ready(function(){
var leftover = jQuery('#top-nav').width() - jQuery('#top-nav ul.menu').width();
var item_width = leftover / (jQuery('#top-nav ul.menu > li').size() - 1);
jQuery('#top-nav ul.menu > li').css('padding-right', item_width);
jQuery('#top-nav ul.menu > li:last-child').css('padding-right', '0');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment