开发者

Better solution for changing children color on parent hover

开发者 https://www.devze.com 2023-03-29 09:56 出处:网络
Is there very better one line crossbrowser solution to change children text colour via css? Need to make all text red on hover div

Is there very better one line crossbrowser solution to change children text colour via css?

Need to make all text red on hover div

html:

<div><span class="gray">I'm a lion!</span><spa开发者_Go百科n>Arrrrr!!!</span></div>

css:

div {color:black};
.gray {color:gray;}
div:hover {color:red;}

I thought only this

div:hover, div:hover .gray {color:red;}


your own...

div:hover, div:hover .gray {color:red;}

...is as good a solution as any, really. If you want to match other classes/elements as well you can use a star;

div:hover, div:hover * { color:red; }

demo at http://jsfiddle.net/h5BaU/

0

精彩评论

暂无评论...
验证码 换一张
取 消