简体   繁体   English

更改鼠标悬停CSS上的所有内容

[英]change everything on mouse hover CSS

I have the html code something like this: 我有这样的html代码:

<li class="sprite-ps2 wishlist">
<a href="/wishlist/">
My Wish
<br>
List
<p>
<i class="fa fa-list-alt fa-3x"></i>
</p>
</a>
</li>

I need to change background of li in blue color and everything inside of them to be color:white on mouse hover on the li element. 我需要将li的背景更改为蓝色,并将其中的所有内容更改为color:鼠标悬停在li元素上的白色。

See this fiddle , you need to set background blue for li:hover , and li:hover * to be color white 看到这个小提琴 ,您需要将li:hover设置为蓝色,而li:hover *设置为白色

 li:hover { background: blue; } li:hover, li:hover * { color: #fff; } 
 <li class="sprite-ps2 wishlist"> <a href="/wishlist/"> My Wish <br> List <p> <i class="fa fa-list-alt fa-3x"></i> </p> </a> </li> 

Put the following in a <style> element or a .css file: 将以下内容放入<style>元素或.css文件中:

li:hover {
    background-color: blue;
    color: white;
}

Because all child elements inside <li> inherit the properties of their parent, they will have a white color (and a blue background too if they don't specify their own). 由于<li>中的所有子元素都继承其父元素的属性,因此它们将具有白色(如果未指定自己的颜色,则背景也会为蓝色)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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