React pseudo selector inline styling

后端 未结 2 515
感动是毒
感动是毒 2020-12-13 18:53

What do you think are good ways to handle styling pseudo selectors with React inline styling? What are the gains and drawbacks?

Say you have a styles.js file for eac

2条回答
  •  暖寄归人
    2020-12-13 19:32

    Is there a reason you're not styling the pseudo selectors with your label-hover class like this? Or am I misunderstanding your question?

    .label-hover {
       color: orange;
       opacity: 0.5;
    }
    
    .label-hover:hover {
       opacity: 1;
    }
    

    You can't style pseudo selectors with inline styling (CSS Pseudo-classes with inline styles), and I think using javascript to see if the element is hovered is an unnecessarily complicated and hackish way of doing it.

提交回复
热议问题