【发布时间】:2021-12-08 00:26:20
【问题描述】:
所以,我认为这可能是一个非常微小的实施问题。我曾经将样式表与我的 component.js 文件完全分开,但最近,我开始看到使用样式化组件、情感、制作样式等在组件内编写样式的一些好处。我在一个虚拟项目上进行了尝试并开始实现我现在正在开发的应用程序的一些组件上。原因主要是更易于管理、开发经验,而且它对我有用。
但后来我发现自己陷入了覆盖现有 mui 样式的问题。
例如,我正在使用 material-ui 来制作这个手风琴组件。还有一个嵌套属性
.MuiAccordionSummary-root.Mui-expanded {
min-height: 64px;
}
编辑这是我的 sass 文件会很容易,但是如何使它与 make 样式一起使用?
我现在的样式是这样的
const useStyles = makeStyles((theme) => ({
root: {
borderBottom: '0.5px solid',
borderBottomColor: theme.palette.primary.main,
marginBottom: '16px',
maxHeight: '35px',
},
summary: {
backgroundColor: theme.palette.complimentory.main,
borderBottom: '0.5px solid',
borderBottomColor: theme.palette.primary.main,
maxHeight: '35px',
height: '35px',
},
title: {
fontFamily: 'Helvetica',
fontStyle: 'normal',
fontWeight: 'normal',
fontSize: '14px',
lineHeight: '14px',
letterSpacing: '0.266667px',
textTransform: 'uppercase',
},
content: {
marginTop: '15px',
fontSize: '14px',
fontStyle: 'normal',
lineHeight: '16.8px',
letterSpacing: '0.375px',
fontWeight: '400',
fontFamily: 'Helvetica',
textAlign: 'left',
},
}))
我正在努力将它定位在 makestyles 中,我认为这一定是可能的,因为我不习惯它,所以我很难过。
【问题讨论】:
-
您似乎在寻找嵌套选择器,在这里查看material-ui.com/styles/basics/#nesting-selectors。
标签: css reactjs material-ui