doniyor
doniyor

Reputation: 37904

simple css issue - how to change anchor inside li if li:hover

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

Answers (5)

user2957312
user2957312

Reputation:

.horizmenu li:hover, a:active {
text-decoration: none;
color: #ffffff;
}

Upvotes: 1

heavyrick
heavyrick

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

Tomzan
Tomzan

Reputation: 2818

Just add this css class:

.horizmenu > li:hover > a
{
    color: white;
}

jsFiddle

Upvotes: 1

cbr
cbr

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

Deryck
Deryck

Reputation: 7668

li:hover a {
    color: #F0F;
}

Upvotes: 5

Related Questions