【发布时间】:2022-01-25 05:19:29
【问题描述】:
希望你们一切都好。
我在寻找如何让我的 MUI Grid 占据它所嵌套的 Box 组件的整个宽度时遇到问题。
我希望右边的空白空间被整个网格占用,但我似乎无法找到关于如何解决此问题的简明答案。
这是我在 VS Code 中的代码:
这是网格的文本代码:
<Grid item key={days}>
<Box
key={days}
sx={{
width: 150,
height: 150,
backgroundColor: 'primary.dark',
'&:hover': {
backgroundColor: 'primary.main',
opacity: [0.9, 0.8, 0.7],
},
}}
/>
</Grid>
);
}
return (
<Grid container spacing={1}>
{/* And here I render the box array */}
{box}
</Grid>
);
这是父元素的真实文本代码:
// Parent Element
<Container>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
width: 1,
}}
>
{/* The Title of The Page */}
<Typography align="center" variant="h4" mt={2} mb={2} sx={{ fontWeight: 'bold' }}>
{t('Happy Chocolate Days!')}
</Typography>
{/* My Calendar Grid Component Inside The Box Component */}
<Calendar />
</Box>
</Container>
提前感谢您的帮助
【问题讨论】:
标签: reactjs material-ui css-grid