How can I calculate and set the width of my child "flare" out menus"?
Posted on 2011-03-14
I've got a main menu for my site that is being build using a menu adapter class that basically builds the menu and it's children menus based on giving the menu a certain class name. The menu items are pulled from a database, the so the items can and will vary in their length. Presently the only way to make sure that all the menu items, (sub, sub-sub etc...) show up on a single line is to "eye ball" the longest item (in fire bug) and then set the with (static) within the CSS that holds the hook for that particular sub menu. This is fine, accept that it makes some of the sub menus much wider than they have to be, simply because the min-width has to be set to longest menu item. I was wondering if there is a way to calculate the with for the menus (and sub menus) based on the length of the items within them? maybe using jQuery or something? Just curious....