Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 922
  • Last Modified:

CSS horizontal drop down menu not showing correctly in IE

Hello,

I am trying to do a pure CSS menu and am having issues - especially with IE. The code I borrowed from displays correctly in IE but mine doesn't. I did add some CSS for the sub-level menus but I can't figure out what is causing the issue.

Here is the site that I used as an example which displays correctly in IE7:
http://www.cssplay.co.uk/menus/centered.html

Here is the html I am using:
<div id="menu_cont">
  <div id="menu">

    <ul id="nav">
      <li><a href="index.htm" class="top_parent">HOME</a></li>
      <li><a href="opportunities.htm" class="top_parent">OPPORTUNITIES</a>
          <ul>
            <li><a href="opportunities/current_promotions.htm">Current Promotions</a></li>
            <li><a href="opportunities/go_green.htm">Go Green With CPS</a></li>
            <li><a href="opportunities/news_events.htm">News/Events</a></li>

            <li><a href="opportunities/partner_rewards.htm">Partner and Rewards Programs</a></li>
            <li><a href="opportunities/training.htm">Training</a></li>
          </ul>
      </li>
      <li><a href="opportunities/credit.htm" class="top_parent">CREDIT</a></li>
      <li><a href="products/product_lines.htm" class="top_parent">PRODUCTS</a>
          <ul>

            <li><a href="products/cut_sheets.htm">Cut Sheets</a></li>
            <li><a href="products/product_lines.htm">Product Lines</a>
                <ul>
                  <li><a href="products/irrigation.htm">Irrigation</a></li>
                  <li><a href="products/landscape.htm">Landscape</a></li>
                  <li><a href="products/lighting.htm">Lighting</a></li>

                  <li><a href="products/pump.htm">Pump</a></li>
                  <li><a href="products/ponds_water_features.htm">Ponds and Water Features</a></li>
                </ul>
            </li>
            <li><a href="products/request_catalog.htm">Request a Catalog</a></li>
          </ul>
      </li>

      <li><a href="locations/branch_offices.htm" class="top_parent">LOCATIONS</a>
          <ul>
            <li><a href="locations/branch_offices.htm">Branch Offices</a></li>
            <li><a href="locations/territory_sales.htm">Territory Salespeople</a></li>
          </ul>
      </li>
      <li><a href="why_cps/inside_cps.htm" class="top_parent">WHY CPS</a>

          <ul>
            <li><a href="why_cps/cps_showcase.htm">CPS Showcase</a></li>
            <li><a href="why_cps/inside_cps.htm">Inside CPS</a></li>
            <li><a href="why_cps/employee_corner.htm">Employee Corner</a></li>
          </ul>
      </li>
      <li><a href="links.htm" class="top_parent">LINKS</a></li>

      <li><a href="employment/current_openings.htm" class="top_parent">EMPLOYMENT</a>
          <ul>
            <li><a href="employment/benefits.htm">Benefits</a></li>
            <li><a href="employment/current_openings.htm">Current Openings</a></li>
          </ul>
      </li>
      <li><a href="locations/policies.htm" class="top_parent">POLICIES</a></li>

    </ul>
  </div>
</div>

I've attached the css for the menu as a snippet. Also, here is the link to the full css:
http://cpsdistributors.com/test/cps_styles.css

Here is the ie only style sheet:
#menu {
  float:left;
  }
#menu a {
  float:left;
  display: inline;
  }
#menu li {
  float:left;
  }
.container {display:inline-block;}

Thank you!
#menu_cont {
	width:900px;
	height: 20px;
	padding-top:9px;
	margin:0 auto;
	background: url(images/menu_bkgnd.jpg) no-repeat center top;
}
/*begin menu*/
#menu{
	font: bold 11pt "Trebuchet MS", Tahoma, Arial, sans-serif;
	margin:0 auto;
	padding:0;
	list-style-type:none;
    white-space:nowrap;
	display:table;
}
#menu a{
	width:auto;
	color: #fff;
    display:block;
	text-decoration: none;
    white-space:nowrap;
	padding:0px 16px;
}
#menu li { /* all list items */
	display:table-cell;
	background: none;
    white-space:nowrap;
  }
.container {clear:both; text-decoration:none;}
#menu li li {
	width: 100%;
	display: block;
	}
#menu li li li{
	width: 100%;
	display: block;
	}
#menu li ul{
/*Make the sub list items invisible*/
	display: none;	
	left: -999em;
	position: absolute;
	}
#menu li:hover ul ul, #menu li.over ul ul{
/*Make the second-level list items invisible*/
	display: none;
	position: absolute;
	left: -999em;
}
#menu li:hover ul, #menu li.over ul{ 
/* lists nested under hovered list items */
	display: block;
	left: auto;
	font: bold 10pt "Trebuchet MS", Verdana, Arial, sans-serif;
	white-space: nowrap;
	background-color: #7FA97F;
	padding: 6px 0px;
	filter:alpha(opacity=90);
	-moz-opacity:.90;
	opacity:.90;
	text-align: left;
}
#menu li li:hover ul, #menu li li.over ul { 
/* second-level lists nested under hovered list items */
	display: block;
	left: 90%;
	width: auto;
	top: 16px;
	font: bold 10pt "Trebuchet MS", Verdana, Arial, sans-serif;
	white-space: nowrap;
	background-color: #7FA97F;
	padding: 6px 0px;
	filter:alpha(opacity=100);
	-moz-opacity:1.0;
	opacity:1.0;
	text-align: left;
}
#menu a, #menu a:visited {color:#fff; text-decoration:none; }
#menu a:hover, #menu a:active {color:#000; text-decoration:none; 
	background-color: #96BB96;}
/*end menu*/

Open in new window

0
maxms
Asked:
maxms
  • 5
  • 4
  • 3
1 Solution
 
EMB01Commented:
What about it doesn't display properly in IE?
0
 
maxmsAuthor Commented:
It stacks vertically in IE7:
http://www.cpsdistributors.com/test
0
 
EMB01Commented:
Have you tried adding clear: left; to your CSS like this...
#menu li { /* all list items */
      display:table-cell;
      background: none;
                     white-space:nowrap;
                     clear: left;
}

Or, you could try adding display: inline; to the primary li node so that it stacks left to right...
#menu li { /* all list items */
      display:table-cell;
      background: none;
                     white-space:nowrap;
                     display: inline;
}

Let me know if these don't work for you, then we can take a closer look and try to work somehting else out.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
David S.Commented:
IE7 doesn't support display:table-cell

Try adding these rules:

*:first-child+html #menu li { /* for IE7 */
  display: inline-block;  
}
* html #menu li { /* for IE5-6 */
   display: inline;
  display: inline-block;  
}

Here's another article on this: http://www.tyssendesign.com.au/articles/css/centering-a-dropdown-menu/
0
 
David S.Commented:
On second thought, this might work better:

#menu li { /* all list items */
  display: inline-block;
  display: table-cell;
  background: none;
  white-space: nowrap;
}
*:first-child+html #menu li { /* for IE7 */
  display: inline;
}
* html #menu li { /* for IE5-6 */
  display: inline;
}

0
 
maxmsAuthor Commented:
Thank you both for your comments but none of these options worked. So, I went back to my original CSS, which didn't use table display and added a few things from the article that Kravimir posted and it now displays horizontally centered in IE7 (woo-hoo!) except that these problems also show in IE7:

1. It is wrapping to the next line. I put the following into an IE7-only css doc but it doesn't appear to be picking it up:
*html #menu a{
      padding:0px 14px;
}

2. The second-level child menu (on the 'Products' drop-down off of the 'Product Lines' child) Isn't displaying correctly. You can see the beginning of it, but it cuts off at the end of the first child menu.

The original CSS is below.
#menu_cont {
	width:900px;
	height: 20px;
	padding-top:9px;
	margin:0 auto;
	background: url(images/menu_bkgnd.jpg) no-repeat center top;
	text-align: center;
}
/*begin menu*/
#menu, #menu ul{
	font: bold 11pt "Trebuchet MS", Tahoma, Arial, sans-serif;
	margin:0 auto;
	padding:0;
	list-style-type:none;
    white-space:nowrap;
	text-align: center;
}
#menu a{
	width:auto;
	color: #fff;
    display:block;
	text-decoration: none;
    white-space:nowrap;
	padding:0px 16px;
}
#menu li { /* all list items */
	float: left;
	position: relative;
	width: auto;
	background: none;
}
#menu li li {
	width: 100%;
	}
#menu li li li{
	width: 100%;
	}
#menu li ul{
/*Make the sub list items invisible*/
	display: none;	
	left: -999em;
	position: absolute;
	}
#menu li>ul{
	top: auto;
	left: auto;
}
#menu li:hover ul ul, #menu li.over ul ul{
/*Make the second-level list items invisible*/
	display: none;
	position: absolute;
	left: -999em;
}
#menu li:hover ul, #menu li.over ul{ 
/* lists nested under hovered list items */
	display: block;
	left: auto;
	font: bold 10pt "Trebuchet MS", Verdana, Arial, sans-serif;
	white-space: nowrap;
	background-color: #7FA97F;
	padding: 6px;
	filter:alpha(opacity=90);
	-moz-opacity:.90;
	opacity:.90;
	text-align: left;
}
#menu li li:hover ul, #menu li li.over ul { 
/* second-level lists nested under hovered list items */
	display: block;
	left: 100%;
	width: auto;
	top: -6px;
	font: bold 10pt "Trebuchet MS", Verdana, Arial, sans-serif;
	white-space: nowrap;
	background-color: #7FA97F;
	padding: 6px;
	filter:alpha(opacity=100);
	-moz-opacity:1.0;
	opacity:1.0;
	text-align: left;
}
#menu a, #menu a:visited {color:#fff; text-decoration:none; }
#menu a:hover, #menu a:active {color:#000; text-decoration:none; 
	background-color: #96BB96;}
/*end menu*/

Open in new window

0
 
maxmsAuthor Commented:
Ok - fixed the wrapping by just lowering the padding to 15px. Now I just need to figure out why the second-level child is displaying so oddly... any help would be greatly appreciated!!!

Thank you!
0
 
David S.Commented:
In Standards mode, IE7 ignores the "* html" filter. Use the "*:first-child+html" filter instead.

More information:
http://www.dynamicsitesolutions.com/css/filters/star-html/
http://www.dynamicsitesolutions.com/css/filters/first-child-plus-html/
0
 
David S.Commented:
<!--[if IE7]>

needs to be

<!--[if IE 7]>

A space is required before the number.

I don't see what's causing the current IE7 issue. I think we've reached the point where you're going to have to comment out each declaration (property/value pair) and test to see if it makes a difference one at a time to find the problem.
0
 
EMB01Commented:
Maybe change this:
#menu li li:hover ul, #menu li li.over ul {
/* second-level lists nested under hovered list items */
      display: block;
      left: 100%;
      width: auto;
      top: -6px;
      font: bold 10pt "Trebuchet MS", Verdana, Arial, sans-serif;
      white-space: nowrap;
      background-color: #7FA97F;
      padding: 6px;
      filter:alpha(opacity=100);
      -moz-opacity:1.0;
      opacity:1.0;
      text-align: left;
}

To this:
#menu li li:hover ul, #menu li li.over ul {
/* second-level lists nested under hovered list items */
      display: block;
      left: auto;
      top: -6px;
      font: bold 10pt "Trebuchet MS", Verdana, Arial, sans-serif;
      white-space: nowrap;
      background-color: #7FA97F;
      padding: 6px;
      filter:alpha(opacity=100);
      -moz-opacity:1.0;
      opacity:1.0;
      text-align: left;
}
0
 
maxmsAuthor Commented:
None of this is working, so I will do some intense testing today and let you know how it goes. Otherwise I may have to create the menu using JavaScript...
0
 
maxmsAuthor Commented:
I figured it out - I just had to remove this from the third level list style:

"filter:alpha(opacity=100);"

Thanks for trying!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now