Setting CSS pseudo-class rules from JavaScript

后端 未结 13 1965
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 01:01

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:hove

13条回答
  •  忘掉有多难
    2020-11-22 01:39

    If you use REACT , There is something called radium. It is so useful here :

    • Add handlers to props if interactive styles are specified, e.g. onMouseEnter for :hover, wrapping existing handlers if necessary

    • If any of the handlers are triggered, e.g. by hovering, Radium calls setState to update a Radium-specific field on the components state object

    • On re-render, resolve any interactive styles that apply, e.g. :hover, by looking up the element's key or ref in the Radium-specific state

提交回复
热议问题