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
  • 4,062
  • 4
  • 31
  • 67

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
  • 4,200
  • 19
  • 28
2

Try:

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

You need to select both :hover and ::before

Florin Pop
  • 5,105
  • 3
  • 25
  • 58