【发布时间】:2021-07-16 23:23:14
【问题描述】:
当在我的 react 应用程序中使用来自 @material-ui/core 的 IconButton 时,我应用了一个 className classes.myCloseButtonstyle,结果发现它与 css 类 .css-1743419-MuiButtonBase-root-MuiIconButton-root 相比具有较低的特异性(见下面的屏幕截图)。
当我在这里查看文档时https://next.material-ui.com/components/dialogs/#customized-dialogs
顺序与我在上面的屏幕截图中得到的不同。 classes.myCloseButtonstyle 比 .css-1uaxfgw-MuiButtonBase-root-MuiIconButton-root 类具有更高的特异性(下面的屏幕截图是材料 ui doc 中的示例代码)
我的反应材料 ui 设置可能有什么问题?我需要让classes.myCloseButtonstyle 赢得特异性。不,我的意思是,我需要订购.css-1uaxfgw-MuiButtonBase-root-MuiIconButton-root 和
classes.myCloseButtonstyle 被反转。
material-ui doc 中的样式顺序:
classes.myCloseButtonstyle
2..css-1uaxfgw-MuiButtonBase-root-MuiIconButton-root
我的应用程序中的样式顺序:
.css-1uaxfgw-MuiButtonBase-root-MuiIconButton-rootclasses.myCloseButtonstyle
我需要将顺序更改为:
classes.myCloseButtonstyle.css-1uaxfgw-MuiButtonBase-root-MuiIconButton-root
【问题讨论】:
-
你可以使用
!important来强加你的风格。 -
是的,但我需要不同的解决方案。在这种情况下,我不想使用
!important。
标签: javascript css reactjs material-ui material-design