Просто содержание внутри <Grid>
не сработает, но если вы поместите его в <div>
или <Paper>
, вы получите то, что вам нужно ...
релевантно js:
const useStyles = makeStyles(theme => ({
root: {
flexGrow: 1
},
grid: {
textAlign: "center",
color: theme.palette.text.secondary
},
span: {
border: "1px solid pink",
backgroundColor: "lightpink`"
},
span2: {
border: "1px solid green",
backgroundColor: "lightgreen"
},
span3: {
border: "1px solid blue",
backgroundColor: "lightblue"
},
}));
const App = () => {
var classes = useStyles();
return (
<div className={classes.root}>
<Hello name="React" />
<p>Start editing to see some magic happen :)</p>
<br />
<Grid container spacing={10}>
<Grid item xs className={classes.grid}>
<div className={classes.span}>CONTENT</div>
</Grid>
<Grid item xs className={classes.grid}>
<div className={classes.span}>CONTENT</div>
</Grid>
</Grid>
<hr />
<Grid container spacing={8}>
<Grid item xs className={classes.grid}>
<div className={classes.span2}>CONTENT</div>
</Grid>
<Grid item xs className={classes.grid}>
<div className={classes.span2}>CONTENT</div>
</Grid>
</Grid>
<hr />
<Grid container spacing={6}>
<Grid item xs className={classes.grid}>
<div className={classes.span3}>CONTENT</div>
</Grid>
<Grid item xs className={classes.grid}>
<div className={classes.span3}>CONTENT</div>
</Grid>
</Grid>
</div>
);
};
пример стек * здесь