I am using superfish to create a horizontal menu on my website.
The menu items will always vary, as the content is very dynamic. The menu items should not have a fixed width.
When the enough menu items are displayed to fill the entire width of the website, a last menu called ‘More Items’ will be shown.
How would I go about measuring the width of each menu item (li tag), so that i can limit the items shown?
The problem is that I can not depend on a certain font to achieve this. Font’s must be, whatever is available on the visitors machine.
Thanks for your input
Here’s one way to do this…
example jsfiddle
In that middle segment I’m totaling up the widths of each menu item and when a threshold is met (the maxWidth) I’m returning those menu items so that I can add them to the “More Items” menu (in the final step)