reactjs - 在主要区域周围设置灰色背景
问题描述
我正在尝试使用材料 ui 来了解这个应用程序的外观:
目前,我的应用程序如下所示:
我需要做几件事。在关键字处理器文本周围放置某种框,在其下方的内容周围放置一个框,将中心区域框的背景颜色设置为白色,并将其余区域的背景区域设置为灰色。
任何想法如何修改下面的代码来做到这一点?
<ThemeProvider theme={theme}>
</ThemeProvider>
<div>
<ThemeProvider theme={theme}>
<Container>
{/* <Box bgcolor="primary.main"> */}
<Grid container spacing={2}>
{/* <Grid xs={12}>
<AppBar />
<br />
</Grid> */}
<Grid item xs={12}>
<Typography variant="h6" gutterBottom>
Keyword Processor
</Typography>
{/* <br /> */}
</Grid>
<Grid item xs={6}></Grid>
<Grid item xs={6}>
<Box textAlign="right">
<Button
color="primary"
// mt={5}
onClick={this.inputToOutput}
//**********************
>
A-Z
</Button>
</Box>
{/* <Typography align="right">A-Z Frequency</Typography>{' '} */}
</Grid>
<Grid item xs={6}>
<TextField
label="Input Keywords"
fullWidth
multiline
rows={10}
variant="outlined"
margin="normal"
onChange={this.handleInputText}
defaultValue={defaultInputText}
/>
<br />
<Button
variant="contained"
color="primary"
mt={5}
onClick={this.inputToOutput}
//**********************
>
Parse
</Button>
<Button
variant="contained"
color="secondary"
mt={5}
// onClick={this.parseInput}
>
Clear
</Button>
<br />
<br />
<Checkboxes
handleDedupe={this.handleDedupe}
handleRemoveNumbers={this.handleRemoveNumbers}
handleConvertToLowercase={this.handleConvertToLowercase}
handleOneWordPerLine={this.handleOneWordPerLine}
handleAddCommas={this.handleAddCommas}
handleAddCommasSpace={this.handleAddCommasSpace}
/>
</Grid>
<Grid item xs={6}>
<TextField
label="Output Keywords"
fullWidth
multiline
rows={30}
variant="outlined"
margin="normal"
value={this.state.outputText}
/>
<Button
variant="contained"
color="primary"
mt={5}
onClick={this.clearOutput}
>
Copy
</Button>
<Button
variant="contained"
color="secondary"
mt={5}
onClick={this.clearOutput}
>
Clear
</Button>
</Grid>
<Grid>
<br />
<br />
</Grid>
</Grid>
{/* </Box> */}
</Container>
</ThemeProvider>
</div>
</>```
解决方案
你不需要做这一切,这是你可以做的。我相信theme
您添加的ThemeProvider
内容是自定义的,将主题文件pallete
对象编辑为background
颜色 iepaper
和default
,default
颜色就是您所需要的。
这是我的:
import { createMuiTheme } from '@material-ui/core/styles';
// Main Material UI theme
const theme = createMuiTheme({
palette: {
background: {
paper: '#fff',
default: '#fafafa',
},
},
});
export default theme;
将“#fafafa”更改为您想要的颜色。
如果您没有创建自定义主题,只需复制我的然后将其导入您的ThemeProvider
,它将更改您所有 html 页面中正文的背景。
推荐阅读
- google-cloud-platform - Google Cloud Run 在 Authorization 标头中屏蔽 Bearer 令牌
- jmeter - Jmeter Webdriver打开空浏览器
- python - 如何检查字符串是否为数字忽略非单词字符?
- assembly - 为什么我需要从 LDR 指令中的标签中减去 1?
- elasticsearch - Fluentd 无法使用 Elasticsearch 创建索引
- vue.js - 使用自定义表体实现选择 Vuetify 数据表的所有行
- python - 如何使用python以最有效的方式将大文件上传到elasticsearch?
- laravel - POST http://localhost:8000/broadcasting/auth 403(禁止)/用于客户服务聊天,我只需要管理员身份验证
- python-3.x - 有没有办法为推送交付类型的 Google Pub/Sub 订阅设置标签?
- kotlin - Kotlin 中一个类和接口的多重继承