CSS Tip: Use :not to Save Time and Lines of Code - The Bold Report (theboldreport.net)
over 6 years ago from Tim Smith, Maker of stuff
over 6 years ago from Tim Smith, Maker of stuff
:hover:not(:active) { ... }
has been one of my favorite selectors for a while.
oooooooo
I'm squinting trying to decipher what I'm looking at. Can you put the jelly on the lower shelf for the rest of us (me). What does this do?
As far as I can tell this should be a rule which only works when you are hovering a button but not clicking it (buttons are :active while you click them).
For example if you want a button to get larger when you hover it, but shrink back to normal when you click it.
oOOooh, I think I get it. Is that commonly desirable functionality?
Not super common, but not exactly rare either. Most buttons/links just change color or background when you hover them and maintain that look as you click.
In the example used in the post. I think you could also use the lobotomized owl technique
.post + .post { border-top: 1px solid #eee; margin-top: .5rem; padding-top: .5rem; }
Yes! That is correct!
This is really good when you want to create a class that overrides most specificity. I use it to apply a blanket screen-reader-only class.
CSS still treats this as having an ID even though you're technically saying it doesn't have an ID, so it will override any class declaration regardless of its placement in your CSS document. The only thing that could override it would be another ID or an inline style.
When it's used properly it's a beautiful thing, but the propensity of developers to abuse it is widespread. I work on a large scale application and I've had to all but ban it.
I'd be curious to know what problems with this you've run across that requires an all out ban on its use. That seems extreme to me but maybe I've missed something here.
Yes. I'd love to hear what problems you've had too.
Have had similar problems — particularly where the first folks on a project don't recognize that Chrome doesn't allow multiple args within ()
Designer News
Where the design community meets.
Designer News is a large, global community of people working or interested in design and technology.
Have feedback?
Login to Comment
You'll need to log in before you can leave a comment.
LoginRegister Today
New accounts can leave comments immediately, and gain full permissions after one week.
Register now