gpt4 book ai didi

css - 为什么 MuiThemeProvider 会覆盖组件样式?

转载 作者:太空宇宙 更新时间:2023-11-04 01:00:42 25 4
gpt4 key购买 nike

我有一个使用 MuiThemeProvider 的外部组件:

<MuiThemeProvider theme={full_theme_e}>
<div>
<AppBar />
<Filter />
</div>
</MuiThemeProvider>

在我的过滤器组件中,我定义了一个自定义样式:

const styles = {
expansionPanel: {
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
}
};

应用于组件:

<ExpansionPanel className={classNames(classes.expansionPanel, className)}

并在我的导出中使用样式:

export default withStyles(styles)(Filter);

问题是我的自定义样式被 MuiThemeProvider 覆盖了,为什么? Chrome showing style being overwritten

最佳答案

const styles = {
expansionPanel: {
'&:first-child': {
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
}
}
};

同样适用于:last-child, :nth-child...

CSS 冒号选择器的语法:

'&:[selector]': {
...
}

关于css - 为什么 MuiThemeProvider 会覆盖组件样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53431218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com