This is so damn basic and I have no idea how to make it work.
How do I keep the .selected class underlined while the drop down list anchors have no underline?
The HTML:
<ul id="nav">
<li>
<a href="about.html">about</a>
</li>
<li>
<a href="about.html">about</a>
</li>
<li class="selected">
<a href="work.html">Work</a>
<ul id="second" class="vis">
<li>
<a href="graphicdesign.html">Graphic Design</a>
</li>
<li>
<a href="illustrations.html">Illustrations</a>
</li>
</ul>
</li>
<!-- etcetera -->
The CSS:
ul#nav {
position: relative;
margin-left: 0;
padding-left: 0;
display: inline;
}
ul#nav li {
margin-left: 0;
padding: 3px 15px;
list-style: none;
display: inline;
}
ul#nav li.first {
margin-left: 0;
border-left: none;
list-style: none;
display: inline;
}
ul#second {
position: absolute;
right: -57px;
display: none;
}
.selected {
text-decoration: underline;
}
.selected:hover ul#second {
display: block;
}
.selected:hover ul#second li a {
display: block;
}
a {
text-decoration: none;
}
If you’re more specific with the selector that underlines the link you want, it becomes easier to select other items within that you don’t want underlined. I changed
to:
Also, added
text-decoration: none;like so:See it working on jsfiddle