It looks like this now: old
I want it to look like this: new
I use MUI grid:
<Grid container spacing={2}>
<Grid item xs={12} md={6}>
<Box className="white-card">
....content...
</Box>
</Grid>
<Grid item xs={12} md={6}>
<Box className="white-card">
....content...
</Box>
</Grid>
</Grid>
CodePudding user response:
If you're using MUI v5, you can use the Masonry
component instead of Grid
:
Straight out of the doc example:
import * as React from 'react';
import Box from '@mui/material/Box';
import { styled } from '@mui/material/styles';
import Paper from '@mui/material/Paper';
import Masonry from '@mui/lab/Masonry';
const heights = [150, 30, 90, 70, 110, 150, 130, 80, 50, 90, 100, 150, 30, 50, 80];
const Item = styled(Paper)(({ theme }) => ({
backgroundColor: theme.palette.mode === 'dark' ? '#1A2027' : '#fff',
...theme.typography.body2,
padding: theme.spacing(0.5),
textAlign: 'center',
color: theme.palette.text.secondary,
}));
export default function BasicMasonry() {
return (
<Box sx={{ width: 500, minHeight: 393 }}>
<Masonry columns={4} spacing={2}>
{heights.map((height, index) => (
<Item key={index} sx={{ height }}>
{index 1}
</Item>
))}
</Masonry>
</Box>
);
}
CodePudding user response:
just add height 100% in your white-card class
here is a codesandbox example where i set the height and background color
https://codesandbox.io/s/modest-dirac-dfq0w4?file=/demo.js