简体   繁体   中英

hover doesn't apply background to li css

What's wrong with my :hover below? I dosen't seem to have effect. Tried overflow hidden but it doesn't appear any effect.

.tabs-nav li:hover {

}

demo https://jsfiddle.net/tpd83jxx/

You have to apply the :hover effect in a:hover because you have already applied background-color to a element. Try and add this code.

.tabs-nav a:hover {
  background-color: red;
}

Nothing wrong with the css ,Here you applied background for a tag.

So change the hover to a

.tabs-nav li:hover a {
    color: white;
    background: red;
} 

Below code works for me

.tabs-nav li :hover {
  color: white;
  background: red;
}

If I am not wrong Space is added to apply hover to the child of li. In this case for anchor tag

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM