Style :before on hover

RGS

I have a button:

.button{
 background-color:red;
 color:#fff;
 width:70px;
}
.button:before{
 min-width:0px;
 content: attr(data-number);
}

html:

<div class="button" data-number="5"><a href="javascript:;">button</a></div>

my problem is, I want the content number to be black when user put mouse hover button text. I try:

.button:hover .button:before{
 color:#000;
}

but it is not working.

http://jsfiddle.net/733ogk3f/

Vladimir Serykh

You need to specify :hover and :before at the same time as:

.button:hover:before {
    color:#000;
}

Such CSS selector as .button:hover .button:before points to .button inside .button. But it's not your case.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related