Interesting question. If you're able to show us a working example we could probably be of more help.
However, in theory there's nothing wrong with what you're attempting to do (although not all browsers will like it: particularly IE8 and below).
The important thing to understand here is that :hover
is a pseudo-class, whereas :before
is a pseudo-element.
Here's a quick excerpt from the standard (with thanks to this answer previously on Stack Overflow):
Pseudo-classes are allowed anywhere in selectors while pseudo-elements
may only be appended after the last simple selector of the selector.
The mistake you're making is in your syntax: the order that you're appending them.
Try this instead:
#sidebar .widget li a:hover:before,
#sidebar .widget li a.active:before {
background-position: 65% 65.7%;
}
That should do as you wish. However this isn't going to give you great cross-browser coverage, it's not something that all browsers support of have implemented.
A better approach would be to:
- reset the
:before
element to nothing (overwrite the styles you can't access);
- use a non-repeated background image on the anchor instead (to display the image), and padding-left to give the indentation;
- You can then switch the background-image in whatever fashion you see fit using
:hover
on the anchor in your CSS.
This will give you far better cross-browser compatibility.