Reputation: 37904
I have this code:
<ul class="horizmenu">
<li>
<a>Link</a>
</li>
</ul>
http://jsfiddle.net/pAgS9/ in jsfiddle
I want that If i hover the li
area, the color of a
text should change to white. Now if i hover, it is still black and only if i hover the a
, then it becomes white.
how can i achieve this in css?
Upvotes: 2
Views: 138
Reputation:
.horizmenu li:hover, a:active {
text-decoration: none;
color: #ffffff;
}
Upvotes: 1
Reputation: 394
Change this:
.horizmenu li a:hover, a:active {
text-decoration: none;
color: #ffffff;
}
into this:
.horizmenu li:hover, a:active {
text-decoration: none;
color: #ffffff;
}
Upvotes: 1
Reputation: 2818
Just add this css class:
.horizmenu > li:hover > a
{
color: white;
}
Upvotes: 1
Reputation: 13662
.horizmenu {
width:700px;
list-style-type: none;
margin: 0;
padding: 0;
}
.horizmenu li {
width:80px;
height:20px;
display: inline;
padding: 5px 5px 5px 5px;
border: 1px solid #e0e0e0;
cursor: pointer;
margin-right: 7px;
}
.horizmenu li:active,li:hover{
background-color: #156ac6;
color:white;
}
.horizmenu li a {
text-decoration: none;
}
.horizmenu li a:hover,a:active {
text-decoration: none;
}
Fixed jsFiddle: http://jsfiddle.net/GY2ge/
Upvotes: 1