maxms
asked on
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">OPPORTU NITIES</a>
<ul>
<li><a href="opportunities/curren t_promotio ns.htm">Cu rrent Promotions</a></li>
<li><a href="opportunities/go_gre en.htm">Go Green With CPS</a></li>
<li><a href="opportunities/news_e vents.htm" >News/Even ts</a></li >
<li><a href="opportunities/partne r_rewards. htm">Partn er and Rewards Programs</a></li>
<li><a href="opportunities/traini ng.htm">Tr aining</a> </li>
</ul>
</li>
<li><a href="opportunities/credit .htm" class="top_parent">CREDIT< /a></li>
<li><a href="products/product_lin es.htm" class="top_parent">PRODUCT S</a>
<ul>
<li><a href="products/cut_sheets. htm">Cut Sheets</a></li>
<li><a href="products/product_lin es.htm">Pr oduct Lines</a>
<ul>
<li><a href="products/irrigation. htm">Irrig ation</a>< /li>
<li><a href="products/landscape.h tm">Landsc ape</a></l i>
<li><a href="products/lighting.ht m">Lightin g</a></li>
<li><a href="products/pump.htm">P ump</a></l i>
<li><a href="products/ponds_water _features. htm">Ponds and Water Features</a></li>
</ul>
</li>
<li><a href="products/request_cat alog.htm"> Request a Catalog</a></li>
</ul>
</li>
<li><a href="locations/branch_off ices.htm" class="top_parent">LOCATIO NS</a>
<ul>
<li><a href="locations/branch_off ices.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.h tm" 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.h tm">Inside CPS</a></li>
<li><a href="why_cps/employee_cor ner.htm">E mployee Corner</a></li>
</ul>
</li>
<li><a href="links.htm" class="top_parent">LINKS</ a></li>
<li><a href="employment/current_o penings.ht m" class="top_parent">EMPLOYM ENT</a>
<ul>
<li><a href="employment/benefits. htm">Benef its</a></l i>
<li><a href="employment/current_o penings.ht m">Current Openings</a></li>
</ul>
</li>
<li><a href="locations/policies.h tm" class="top_parent">POLICIE S</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!
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><a href="opportunities.htm" class="top_parent">OPPORTU
<ul>
<li><a href="opportunities/curren
<li><a href="opportunities/go_gre
<li><a href="opportunities/news_e
<li><a href="opportunities/partne
<li><a href="opportunities/traini
</ul>
</li>
<li><a href="opportunities/credit
<li><a href="products/product_lin
<ul>
<li><a href="products/cut_sheets.
<li><a href="products/product_lin
<ul>
<li><a href="products/irrigation.
<li><a href="products/landscape.h
<li><a href="products/lighting.ht
<li><a href="products/pump.htm">P
<li><a href="products/ponds_water
</ul>
</li>
<li><a href="products/request_cat
</ul>
</li>
<li><a href="locations/branch_off
<ul>
<li><a href="locations/branch_off
<li><a href="locations/territory_
</ul>
</li>
<li><a href="why_cps/inside_cps.h
<ul>
<li><a href="why_cps/cps_showcase
<li><a href="why_cps/inside_cps.h
<li><a href="why_cps/employee_cor
</ul>
</li>
<li><a href="links.htm" class="top_parent">LINKS</
<li><a href="employment/current_o
<ul>
<li><a href="employment/benefits.
<li><a href="employment/current_o
</ul>
</li>
<li><a href="locations/policies.h
</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*/
What about it doesn't display properly in IE?
ASKER
It stacks vertically in IE7:
http://www.cpsdistributors.com/test
http://www.cpsdistributors.com/test
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.
#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.
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/
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/
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;
}
#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;
}
ASKER
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.
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*/
ASKER
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!
Thank you!
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/
More information:
http://www.dynamicsitesolutions.com/css/filters/star-html/
http://www.dynamicsitesolutions.com/css/filters/first-child-plus-html/
<!--[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.
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.
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;
}
#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;
}
ASKER
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.