reactjs - 将渐变应用到 Material UI 的主题背景
问题描述
我正在尝试将 MuiTheme 的默认背景颜色设置为渐变,我有以下代码:
export const theme = createMuiTheme({
palette: {
type: "dark",
background: {
default: "linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%)",
},
},
})
但是我注意到 material-ui 将其设置为background-color
并且不允许使用渐变。
有没有办法绕过这个并让它变成background
呢?
解决方案
默认主题背景实际上是由CssBaseline
组件应用的。overrides
您可以使用对象中的属性覆盖它使用的全局默认样式theme
。
export const theme = createMuiTheme({
overrides: {
MuiCssBaseline: {
'@global': {
body: {
background: 'linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%)',
backgroundRepeat: "no-repeat",
backgroundAttachment: "fixed",
},
},
},
},
palette: {
type: "dark",
},
})
推荐阅读
- javascript - HashRouter 在构建时显示 File://
- xslt - 如何使用 xslt 1.0 知道工作日
- c++ - 使用静态 openssl 1.1.1a 编译静态 curl
- javascript - vuejs npm 开发服务器不显示更新的输出
- codeigniter-3 - 找不到您指定的型号 codeigniter-3.1.10
- javascript - 在 billboard.js 中更改轴的粗细
- reactjs - 类型错误:_this2.props.history 未定义
- c# - 如何解决:“元素div不能嵌套在元素'updatepanel'中”
- sql - 如何在 SQL Server 中计算一个字符?
- c - 无法释放结构