如何覆盖React中的物化css
我正在使用react构建简单的应用程序,并使用Materialize css。在我的UserProfile组件类中,导入UserProfile.css如何覆盖React中的物化css,css,reactjs,materialize,Css,Reactjs,Materialize,我正在使用react构建简单的应用程序,并使用Materialize css。在我的UserProfile组件类中,导入UserProfile.cssimport./UserProfile.css /* UserProfile.css */ .custom-class { margin-top: 30 !important; color: pink; } 呈现方法中的UserProfile具有 Title//未应用边距,但颜色为粉红色 我可以选择 标题 这很好,但我更喜欢c
import./UserProfile.css
/* UserProfile.css */
.custom-class {
margin-top: 30 !important;
color: pink;
}
呈现方法中的UserProfile具有
Title//未应用边距,但颜色为粉红色
我可以选择
标题
这很好,但我更喜欢css文件中的样式代码
我不确定这个问题是否与重写无关。您需要使用camelCase作为类名,因此
.customClass
而不是.customClass
/* UserProfile.css */
.custom-class {
margin-top: 30 !important;
color: pink;
}
那么您的导入语句应该如下所示:
从“./UserProfile.css”导入css;
在您的组件中:
标题
请继续阅读了解更多信息。您需要使用camelCase作为类名,因此
.customClass
而不是.customClass
/* UserProfile.css */
.custom-class {
margin-top: 30 !important;
color: pink;
}
那么您的导入语句应该如下所示:
从“./UserProfile.css”导入css;
在您的组件中:
标题
请继续阅读了解更多信息。您的css类中没有
边距顶部的单元
.custom-class {
margin-top: 30px !important;
color: pink;
}
css类中没有边距顶部的单位
.custom-class {
margin-top: 30px !important;
color: pink;
}
您应该在css文件中使用px
,将代码更改为margintop:30px!重要;
并且应该可以工作
如果你想检查css中的覆盖问题,你可以检查你的代码(用鼠标右键点击你的浏览器并选择inspect)并检查它是否交叉。你应该在css文件中使用px
,将你的代码改为margin top:30px!重要;
,它应该可以工作
如果您想检查css中的覆盖问题,可以检查代码(右键单击浏览器并选择inspect)并检查其是否交叉。您好,您应该在css文件中使用px
,请将您的代码更改为margin top:30px!重要;
然后重试again@octobus是的,愚蠢的我,谢谢很多相信我,不要担心:)我也发布了一个答案。祝你的项目好运。@octobus谢谢。我不知道,我必须删除吗te问题(因为该问题与覆盖无关)?您好,您应该在css文件中使用px
。请将您的代码更改为margin top:30px!重要;
然后重试again@octobus是的,愚蠢的我,谢谢很多相信我,不要担心:)我也发布了一个答案。祝你的项目好运。@octobus谢谢。我不知道,我必须删除这个问题吗(因为问题与覆盖无关)?