Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better solution for changing children color on parent hover

Tags:

css

hover

colors

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><span>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;}
like image 202
Shara Avatar asked Aug 21 '11 15:08

Shara


1 Answers

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/

like image 108
xec Avatar answered Nov 03 '22 14:11

xec