如何取消页面中某些元素的样式表规则

发布于 2025-01-17 21:40:35 字数 358 浏览 3 评论 0原文

我使用 ANTD 框架来构建应用程序。 最近,当我导入 antd-theme.css 时,我注意到 ANTD 元素之一存在一个小问题 由于某些原因,CSS 会覆盖某个 ANTD 元素的规则并使其看起来很糟糕。 我不能拒绝使用这个 css 样式表,因为整个应用程序的其他元素都需要它。 所以它被导入到 index.js 中 另外,我无法覆盖这条破坏 ANTD 元素的规则,因为它的样式表有 24844 行。 我永远不会找到到底是什么打破了它。 相信我,我试过了:(
我很好奇是否有可能使某些元素忽略某些样式表? 喜欢某事

<Radio style={{igonereCss}} />

I using ANTD framework for building an app.
And latelly i noticed one small issue with one of ANTD elements when i import antd-theme.css
For some reasons that css overides rules for one ANTD elements and makes it look terrible.
I cannot refuse from using this css stylesheets because it's needed for other elements all over the app.
So it's imported in index.js
Also i cannot overide this rule which breaks ANTD element, because it's stylesheet has 24844 lines.
And i will never find what exectly breaks it.
Believe me I tried:(
I was curiouse is there some how possible to make some element/elements ignore certain stylesheets?
Like something

<Radio style={{igonereCss}} />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

歌入人心 2025-01-24 21:40:35

我认为您可以为您的元素提供一个定义的类,它将使用它,而不是其他样式

<radio class="mystyle">

,然后在您的主要CSS样式表中定义了一种样式。它不必做任何事情,但是它可能会覆盖其他地方发生的样式。

.mystyle {
}

I think you can give your element a class that you define and it will use that over the other styles

<radio class="mystyle">

Then in your main css style sheet just define a style for that. It doesn't have to do anything, but it might override the styles that are happening elsewhere.

.mystyle {
}

恍梦境° 2025-01-24 21:40:35

您可以通过覆盖 css 文件中的默认类(您将从开发人员工具获取所有元素类)来更改特定组件的样式,因此

.ant-radio-checked .ant-radio-inner{
   background-color:#fdfdfd !important;
}

它将全局覆盖样式,仅覆盖特定组件的样式通过给类“test”并覆盖 css 来更新某些 div 中的组件

.test .ant-radio-checked .ant-radio-inner{
   background-color:#fdfdfd !important;
}

,它将仅更新特定组件的样式

you can change style of specific component by overriding default class in your css file (you will get all the element classes from developer tool) for that element

.ant-radio-checked .ant-radio-inner{
   background-color:#fdfdfd !important;
}

as a result it will override the style globally, to override the style for specific component only just wrap the component in some div by giving class "test" and override the css

.test .ant-radio-checked .ant-radio-inner{
   background-color:#fdfdfd !important;
}

and it will update the style for specific component only

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文