Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create custom CSS pseudo-classes?

I am thinking of an alternative to JavaScript in case it's manually disabled by the user, so that instead of prompting them to enabled it, I could, for instance, in some way simulate the click event and change, for instance, the background colour by creating my own :click pseudo-class, just like it works for :hover.

Is such a scenario possible? Is it possible for one to create their own css pseudo-classes that?

like image 996
Angel Politis Avatar asked May 29 '16 08:05

Angel Politis


Video Answer


1 Answers

If your question is, can I create a custom pseudo, example;

div:my-custom-pseudo { }

Then not without some JavaScript libraries.

Tutorial on using it with mooTools and slick

Personally, I haven't used this, so I don't know browser support and this is pretty much the only resource I ever found on custom pseudo classes.

Edit:

So pretty much, no, you can't do what you want, as you will always need JavaScript to do what you want.

like image 149
Mark Avatar answered Oct 26 '22 04:10

Mark