css position - CSS drop down menu positioning in IE7 -
i have css drop down menu works fine in firefox , chrome. sub menus line directly underneath parents. however, in ie7, positioned off side.
css:
/* menu level 1 */ #nav-img { padding-top: 4px; } #main-nav { height: 30px; /* set height want menu */ margin: 0 0 10px; /* give spacing */ width: 600px; display: inline-block; font-family: tahoma, geneva, sans-serif; font-size: 10pt; text-transform: uppercase; } #main-nav ul { margin: 0; padding: 0; /* needed if have not done css reset */ } #main-nav li { display: block; border: 1px solid #000; float: left; line-height: 30px; /* should same #main-nav height */ height: 30px; /* should same #main-nav height */ margin: 0; padding: 0; /* needed if don't have reset */ position: relative; /* needed in order position sub menus */ } #main-nav li { display: block; height: 30px; line-height: 30px; padding: 0 15px; } #main-nav .current-menu-item a, #main-nav .current_page_item a, #main-nav a:hover { color: #000; } /* menu level 2 */ .sub-menu { text-transform: none; } #main-nav ul ul { /* targets sub menus */ display: none; /* hide sub menus view */ position: absolute; top: 30px; /* should same height top level menu -- height + padding + borders */ } #main-nav ul ul li { /* targets submenu items */ float: none; /* overwriting our float above */ width: 240px; /* set width want sub menus be. needs match value set below */ } #main-nav ul ul li { /* target sub menu item links */ padding: 5px 10px; /* give our sub menu links nice button feel */ } #main-nav ul li:hover > ul { display: block; /* show sub menus when hovering on parent */ }
html:
<div id="main-nav"> <ul> <li><a href="a href="#"">home</a></li> <li><a href="a href="#"">services</a> <br /> <ul class="sub-menu"> <li><a href="#">commodities</a></li> <li><a href="#">professional practice</a></li> <li><a href="#">shipping</a></li> <li><a href="#">commercial</a></li> <li><a href="#">corporate structure</a></li> <li><a href="#">dispute resolution , arbitration</a></li> <li><a href="#">international employment</a></li> <li><a href="#">financial re-structuring</a></li> <li><a href="#">intellectual property</a></li> </ul> </li> <li><a href="#">team</a></li> <li><a href="#">news</a></li> <li><a href="#">testimonials</a></li> <li><a href="#">contact</a></li> </ul>
any appreciated.
try this;
#main-nav ul ul { display: none; /* hide sub menus view */ position: absolute; top: 30px; /* should same height top level menu -- height + padding borders */ left: 0; }
ie7 needs left value.
Comments
Post a Comment