Change background of A when mouse in LI

Asked

Viewed 3,258 times

1

I have the following code:

<li class="menu-item">
<a href="http://stanlee.com.br">
<span class="jaw-menu-href-title">Home</span>
</a>
</li>

When I pass the mouse on li I want the background of to switch to white.

I just remember it like this:

.menu-item:Hover{background:white}

2 answers

3


Do it like this :

.menu-item:hover a span{background:white;}

.menu-item:hover a span{background:black;}
<li class="menu-item">
<a href="http://stanlee.com.br">
<span class="jaw-menu-href-title">Home</span>
</a>
</li>

2

ul{}
ul li{}
ul li:hover a{background-color:#ccc;}
ul li a{}
<ul>
<li>
  <a>teste</a>
</li>
</ul>

  • Doesn’t seem to work ;(

  • Yes it works! Look at Jsfiddle!

  • After editing it might be that yes the way it was would not work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.