admin管理员组文章数量:1287489
How can I make the height of grid items 10 and 11 match the height of the grid on the left in MUI Grid?
What I've Tried:
Used
alignItems: "stretch"
- I set
alignItems: "stretch"
on theGrid
, but items 10 and 11 still didn't match the height of the left grid.
- I set
Applied
minHeight: '100%'
- I added
minHeight: '100%'
to theGrid
containing items 10 and 11, but it didn't make a difference.
- I added
Tried
height: "100%"
- I set
height: "100%"
on individualGrid
items, but it didn't achieve the desired result.
- I set
Used
flex: 1
- I applied
flex: 1
to bothGrid
andItem
, but the height still didn't align properly.
- I applied
Set
display: "flex"
andflexDirection: "column"
- I tried making the parent
Grid
display: "flex"
withflexDirection: "column"
, but the height mismatch persisted.
- I tried making the parent
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Paper from '@mui/material/Paper';
import Grid from '@mui/material/Grid2';
const Item = styled(Paper)(({ theme }) => ({
backgroundColor: '#fff',
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.palette.text.secondary,
...theme.applyStyles('dark', {
backgroundColor: '#1A2027',
}),
}));
export default function App() {
return (
<Box sx={{ flexGrow: 1 }}>
<Grid
container
direction="row"
spacing={2}
sx={{
justifyContent: "center",
alignItems: "center",
}}
>
<Grid
container
direction="row"
sx={{
justifyContent: "center",
alignItems: "center",
}}
>
<Grid size={12}><Item>num=1</Item></Grid>
<Grid size={12}><Item>num=2</Item></Grid>
<Grid size={12}><Item>num=3</Item></Grid>
</Grid>
<Grid
container
direction="row"
sx={{
justifyContent: "center",
alignItems: "center",
minHeight:'100%'
}}
>
<Grid size={6}><Item>num=4</Item></Grid>
<Grid size={6}><Item>num=5</Item></Grid>
<Grid size={12}><Item>num=6</Item></Grid>
<Grid size={4}><Item>num=7</Item></Grid>
<Grid size={4}><Item>num=8</Item></Grid>
<Grid size={4}><Item>num=9</Item></Grid>
</Grid>
<Grid
container
direction="column"
sx={{
justifyContent: "flex-end",
alignItems: "stretch",
}}
>
<Grid size={12}><Item>num=10</Item></Grid>
<Grid size={12}><Item>num=11</Item></Grid>
</Grid>
</Grid>
</Box>
);
}
本文标签: layoutMUI Match Height of Items 10 and 11 with Left GridStack Overflow
版权声明:本文标题:layout - MUI Match Height of Items 10 and 11 with Left Grid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741292482a2370627.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论