1

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/

RGS
  • 3,760
  • 2
  • 26
  • 54

2 Answers2

4

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.

Vlad DX
  • 3,429
  • 17
  • 24
2

Try:

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

You need to select both :hover and ::before

Florin Pop
  • 4,997
  • 3
  • 22
  • 57