我最近开始React.js与material-ui图书馆一起。我知道使用的Grid布局系统material-ui。但是,与 不同的是Bootstrap, 是container从头到尾延伸的。说,我想创建一个全局容器来保存最大宽度为 的1140px内容,正确的方法是什么?目前我正在使用withStyles提供者material-ui,如下面的代码示例所示
import React, { Component } from 'react';
import { withStyles } from '@material-ui/core/styles';
const styles = {
contentBody: {
maxWidth: '1140px',
marginLeft: 'auto',
marginRight: 'auto'
}
};
class ContentBody extends Component {
render() {
return (
<Grid container className={this.props.classes.contentBody}>
{this.props.children}
</Grid>
);
}
}
export default withStyles(styles)(ContentBody);
Run Code Online (Sandbox Code Playgroud) 现在我们可以在 material-ui 中配置主题如下。
import { createMuiTheme } from '@material-ui/core/styles';
const theme = createMuiTheme({
palette: {
primary: {
main: '#ff4400'
},
secondary: {
light: '#0066ff',
main: '#0044ff',
contrastText: '#ffcc00',
},
// error: will use the default color
},
});
Run Code Online (Sandbox Code Playgroud)
有没有办法为原色和副色提供渐变配置?恕我直言,微妙的渐变提供了更好的颜色流行并使平面颜色稍微不那么无聊