Css color effect on list and popup menu
In firefox (this doesn't work at all in IE6) I have this code
<div class="menu">
<ul class="nav">
<li><a href="index.html">Home</a></li>
<li><a href="software.html">Software</a>
<ul>
<li>Blah</li>
<li>Blah3</li>
<li>Blah</li>
</ul>
</li>
<li><a href="samples.html">Code Samples</a></li>
<li><a href="resume.html">Resume</a></li>
</ul>
</div>
using this css
ul.nav li:hover,
.nav a:hover
{
background-color:#606060;
color: white;
}
My menu text ("software") turns white and the background turns gray. However, when I move my mouse over to the menu item, the background continues to be gray, but the next one is no longer white! What for? how can i fix this?
0
user34537
a source
to share
3 answers
You will have to rework your css, but if you are doing a main menu submenu, you can make it all work in IE and FF by wrapping the submenu in an 'a' tag.
<div class="menu">
<ul class="nav">
<li><a href="index.html">Home</a></li>
<li><a href="software.html">Software
<ul>
<li>Blah</li>
<li>Blah3</li>
<li>Blah</li>
</ul>
</a>
</li>
<li><a href="samples.html">Code Samples</a></li>
<li><a href="resume.html">Resume</a></li>
</ul>
</div>
Some CSS that shouldn't require JS to work in IE6. Not tested but should work. Note that you also need to add styling and positioning for the subnav, but this still shows the basics.
.menu ul li a {
color: blue;
}
.menu ul li a ul {
display: none;
}
.menu ul li a:hover {
color: white;
}
.menu ul li a:hover ul {
display: block;
}
.menu ul li a:hover ul li {
}
.menu ul li a:hover ul li a {
color: black;
}
.menu ul li a:hover ul li a:hover {
color: red;
}
Then for every submenu you want after the first menu, just add
.menu ul li a:hover ul li a ul {
display: none;
}
.menu ul li a:hover ul li a:hover ul {
display: block;
}
0
a source to share