IE7 Dropdown
As Sotiris mentioned, the easiest fix for IE7 would be to give ul#menu > li > ul
a fixed width. This would cause the child <li>
and <a>
elements to properly take 100% of their parent width.
What's currently happening in IE7 is that your dropdown menu width is being determined by the length of your longest child element on account of the white-space: nowrap
property. IE7 then doesn't properly apply this to the dropdown's <ul>
, which instead takes its width from the top level menu item (104 pixels in your case).
If you still want to keep the dynamic width menus, you can fix it in IE7 with a snippet of jQuery that loops through all your links on load, finds the widest one and sets the parent <ul>
to that width. It should be run in your $(window).load
event handler, just after you set all ul#menu > li ul
to display: block:
// Nodig om de width te kunnen raadplegen
$("ul#menu > li ul").css("display", "block");
// Loop through all dropdowns and find widest child link in each
$('ul.children').each(function(){
// Find widest link in each submenu
var widest = 0;
$(this).children('li').each(function(){
if($(this).width() > widest)
widest = $(this).width();
});
// Set submenu width to widest child link
if(widest != 0)
$(this).width(widest);
});
To fix the centered items, you'll also need to remove the text-align: center
from this rule:
ul#menu > li{
background: url(img/menuitem.png) left top;
display: block;
float: left;
height: 36px;
margin-right: 1px;
position: relative;
width: 104px;
}
Finally, you'll need to make sure the hasLayout flag is set properly on your dropdown links. You can do this by setting zoom: 1
on the following rule:
ul#menu > li > a, ul#menu > li > ul a {
zoom: 1;
display: block;
text-decoration: none;
white-space: nowrap;
}
Firefox 3.5 Submenu Indicator
This is an easier fix. Add the ul#menu > li > ul > li a
declaration and change your span.sf-sub-indicator
rule as follows:
/* Makes the link a coordinate map for span.sf-ub-indicator */
ul#menu > li > ul > li a {
position: relative;
padding-right: 10px;
}
ul#menu > li > ul > li a > span.sf-sub-indicator {
position: absolute;
top: 0;
right: 0;
}
This will absolutely position the indicator to the far right of your link. Note you'll need to apply this fix for IE7 as well otherwise your submenus will be pushed down one link too far.