Skip to content

Instantly share code, notes, and snippets.

@leopic
Created November 14, 2012 22:11
Show Gist options
  • Save leopic/4075208 to your computer and use it in GitHub Desktop.
Save leopic/4075208 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
fixNav();
});
function fixNav() {
var $catLinks = $('.reg-c1'),
catLinksWidth = 0,
doesItFit = false,
moreLinkWidth = $('.more-link').width(),
totalWidth = $('.fake-nav ul').width();
$catLinks.each(function(){
catLinksWidth += $(this).outerWidth(true);
});
if ((catLinksWidth + moreLinkWidth) > totalWidth) {
$catLinks.filter(':last').remove();
fixNav();
} else {
doesItFit = true;
}
return doesItFit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment