Can Reactjs programmatically handle :before?

后端 未结 3 1166
执念已碎
执念已碎 2021-01-19 06:46

I somehow have to programmatically set the width of the :before for a div.

&l
3条回答
  •  清酒与你
    2021-01-19 07:32

    Yes, you can programmatically change the value of pseudo-elements like ::before, ::after in react.

    Here is a trick.

    app.js

    const widthVar = 34;
    const someStyle = {
         "--width": widthVar
    }
    

    style.css

    .something:before{
          width: var(--width),
          // remaining code
    }
    

提交回复
热议问题