本文介绍了可以Reactjs以程序方式haddle:before?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以某种方式必须以编程方式为 c> 的 c>的宽度可以相应改变?

How can I define the someStyle so that the width of the :before of .something``div can change accordingly??

推荐答案

伪元素不能使用内联样式设置样式,如。你必须在样式表中使用 .something:before 选择器来定义 something 类名。这不是React的限制,而是HTML + CSS的设计选择。

Pseudo elements cannot be styled with inline styles as explained in https://stackoverflow.com/a/14141821/368697. You will have to style the something class name in a stylesheet with the .something:before selector. This is not a limitation of React but rather a design choice for HTML + CSS.

如果您需要以编程方式更改伪的宽度:之前元素,它可能更适合作为由React呈现的常规DOM元素。

If you need to programmatically change the width of the pseudo :before element, it is probably more appropriate as a regular DOM element rendered by React.

这篇关于可以Reactjs以程序方式haddle:before?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:08