pseudo-class

CSS Pseudo-classes with inline styles

拜拜、爱过 提交于 2019-11-25 21:59:13
问题 Is it possible to have pseudo-classes using inline styles? Example: <a href=\"http://www.google.com\" style=\"hover:text-decoration:none;\">Google</a> I know the above HTML won\'t work but is there something similar that will? P.S. I know I should use an external style sheet, and I do. I was just curious if this could be done using inline styles. 回答1: No, this is not possible. In documents that make use of CSS, an inline style attribute can only contain property declarations; the same set of

Setting CSS pseudo-class rules from JavaScript

瘦欲@ 提交于 2019-11-25 21:58:39
问题 I\'m looking for a way to change the CSS rules for pseudo-class selectors (such as :link, :hover, etc.) from JavaScript. So an analogue of the CSS code: a:hover { color: red } in JS. I couldn\'t find the answer anywhere else; if anyone knows that this is something browsers do not support, that would be a helpful result as well. 回答1: You can't style a pseudo-class on a particular element alone, in the same way that you can't have a pseudo-class in an inline style="..." attribute (as there is