Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if browser support specified css pseudo-class?

What's concept of detecting support of any css pseudo-class in browser through JavaScript? Exactly, I want to check if user's browser supports :checked pseudo-class or not, because I've made some CSS-popups with checkboxes and needs to do fallbacks for old browsers.

ANSWER: I'm found already implemented method of testing css selectors in a Modernizr "Additional Tests".

like image 759
Raiden Avatar asked Dec 16 '11 09:12

Raiden


People also ask

What is a CSS pseudo class show an example of code of a pseudo class?

A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). For example, the pseudo-class :hover can be used to select a button when a user's pointer hovers over the button and this selected button can then be styled.

What is the use of CSS pseudo class in the Web document?

Use CSS Pseudo-classes to Highlight User's Position For example, when a user hovers over a link, the color and background-color of that link could be reversed. In the following example CSS, all links on a page are stylized as black on a white background, but when a user hovers over the colors are reversed.

How are the CSS selectors matched against the elements by the browser?

CSS Selectors are matched by browser engines from right to left. So they first find the children and then check their parents to see if they match the rest of the parts of the rule.


1 Answers

You can simply check if your style with pseudo-class was applied.

Something like this: http://jsfiddle.net/qPmT2/1/

like image 199
andychups Avatar answered Sep 28 '22 18:09

andychups