简体   繁体   English

(S)CSS React元素选择器

[英](S)CSS React element selector

I'm looking for a simple way to select an existing react element in my css. 我正在寻找一种简单的方法来在CSS中选择现有的react元素。 I've tried searching it but only found confusing answers about tons of libraries I can use, and none seemed to fit what I'm trying to do. 我尝试搜索它,但只找到了关于我可以使用的大量库的令人困惑的答案,而且似乎都找不到适合我尝试做的事情。

I want to have a regular .scss file, where if I have the react element called Foo , I can do something like this: 我想要一个常规的.scss文件,如果我有名为Foo的react元素,则可以执行以下操作:

Foo {
    color: red;
}

This would be great because I could continue with .scss files which I like, and could select components. 这将很棒,因为我可以继续使用我喜欢的.scss文件,并可以选择组件。 How can I do this (or achieve similar behaviour)? 我该怎么做(或达到类似的行为)?

Notice that I'm not the one creating the element so I can't just apply a class to all of them. 请注意,我不是创建元素的人,因此我不能仅将一个类应用于所有元素。

您可以轻松地做到这一点,方法是添加className = Foo并在Sass中通过(.Foo)进行调用,并使用编译器程序将Sass转换为CSS,例如(Prepros),然后将CSS文件作为指向主HTML文件的链接进行调用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM