gpt4 book ai didi

javascript - 在大屏幕上使 material-ui 网格环绕

转载 作者:太空宇宙 更新时间:2023-11-04 05:47:13 25 4
gpt4 key购买 nike

我正在尝试使用 Material UI 网格系统设置一个组件。

到目前为止,这是我组件中的代码

  <Container maxWidth="lg" className={classes.container}>
<Grid container spacing={4}>
<Paper className={classes.paper}>
<Grid item xs={12} lg={6} style={{padding: '10px'}}>
<CardActionArea component="a" href="#">
<Card className={classes.card}>
<div className={classes.cardDetails}>
<CardContent>
<Typography component="h2" variant="h5">
<Title size={'28px'}>Name</Title>
</Typography>
<Typography variant="subtitle1" color="grey">
Occupation
</Typography>
<Typography variant="subtitle1" paragraph>
Mauris eu porttitor dolor. Nulla pellentesque imperdiet sodales. Morbi tincidunt mattis ex eu molestie. Suspendisse scelerisque est vel mi volutpat tincidunt. Nulla felis odio, suscipit accumsan mollis vel, semper eget dui. Etiam eget hendrerit neque, vitae ornare nisi. Duis tincidunt erat vel nulla iaculis, vel viverra orci varius. Duis risus velit, tempus bibendum justo eu, blandit pulvinar libero. Aliquam ornare dui ut risus finibus, sit amet laoreet purus ultricies.
</Typography>
<CardMedia
className={classes.media}
title="image picture"
image="https://www.ucd.ie/sportandfitness/t4media/Banner---PT-Course.jpg" />
</CardContent>
</div>
<p>Hello</p>
</Card>
</CardActionArea>
</Grid>
<Grid item xs={12} lg={6} style={{padding: '10px'}}>
<Card className={classes.card}>
<div className={classes.cardDetails}>
<CardContent>
<Typography component="h2" variant="h5">
<Title size={'28px'}>Name</Title>
</Typography>
<Typography variant="subtitle1" color="grey">
Occupation
</Typography>
<Typography variant="subtitle1" paragraph>
Mauris eu porttitor dolor. Nulla pellentesque imperdiet sodales. Morbi tincidunt mattis ex eu molestie. Suspendisse scelerisque est vel mi volutpat tincidunt. Nulla felis odio, suscipit accumsan mollis vel, semper eget dui. Etiam eget hendrerit neque, vitae ornare nisi. Duis tincidunt erat vel nulla iaculis, vel viverra orci varius. Duis risus velit, tempus bibendum justo eu, blandit pulvinar libero. Aliquam ornare dui ut risus finibus, sit amet laoreet purus ultricies.
</Typography>
<CardMedia
className={classes.media}
title="image picture"
image="https://www.ucd.ie/sportandfitness/t4media/Banner---PT-Course.jpg" />
</CardContent>
</div>
<p>Hello</p>
</Card>
</Grid>
</Paper>
</Grid>
</Container>

这是桌面 View

enter image description here

问题是,无论何时在桌面模式下查看,我都希望两个网格在同一行上。它们非常适合移动设备和较小的屏幕,但我无法将这两个组件包装在桌面设备中,我该如何更改?

最佳答案

我认为问题是因为您使用了 <Paper> 引起的Grid 容器中的组件。<Grid> 的直接 child 容器,应该是另一个<Grid>组件。

尝试包装 <Paper> <Grid>周围.像这样:

<Container maxWidth="lg" className={classes.container}>
<Paper className={classes.paper}>
<Grid container spacing={4}>
<Grid item xs={12} lg={6} style={{padding: '10px'}}>
<CardActionArea component="a" href="#">
<Card className={classes.card}>
<div className={classes.cardDetails}>
<CardContent>
<Typography component="h2" variant="h5">
<Title size={'28px'}>Name</Title>
</Typography>
<Typography variant="subtitle1" color="grey">
Occupation
</Typography>
<Typography variant="subtitle1" paragraph>
Mauris eu porttitor dolor. Nulla pellentesque imperdiet sodales. Morbi tincidunt mattis ex eu molestie. Suspendisse scelerisque est vel mi volutpat tincidunt. Nulla felis odio, suscipit accumsan mollis vel, semper eget dui. Etiam eget hendrerit neque, vitae ornare nisi. Duis tincidunt erat vel nulla iaculis, vel viverra orci varius. Duis risus velit, tempus bibendum justo eu, blandit pulvinar libero. Aliquam ornare dui ut risus finibus, sit amet laoreet purus ultricies.
</Typography>
<CardMedia
className={classes.media}
title="image picture"
image="https://www.ucd.ie/sportandfitness/t4media/Banner---PT-Course.jpg" />
</CardContent>
</div>
<p>Hello</p>
</Card>
</CardActionArea>
</Grid>
<Grid item xs={12} lg={6} style={{padding: '10px'}}>
<Card className={classes.card}>
<div className={classes.cardDetails}>
<CardContent>
<Typography component="h2" variant="h5">
<Title size={'28px'}>Name</Title>
</Typography>
<Typography variant="subtitle1" color="grey">
Occupation
</Typography>
<Typography variant="subtitle1" paragraph>
Mauris eu porttitor dolor. Nulla pellentesque imperdiet sodales. Morbi tincidunt mattis ex eu molestie. Suspendisse scelerisque est vel mi volutpat tincidunt. Nulla felis odio, suscipit accumsan mollis vel, semper eget dui. Etiam eget hendrerit neque, vitae ornare nisi. Duis tincidunt erat vel nulla iaculis, vel viverra orci varius. Duis risus velit, tempus bibendum justo eu, blandit pulvinar libero. Aliquam ornare dui ut risus finibus, sit amet laoreet purus ultricies.
</Typography>
<CardMedia
className={classes.media}
title="image picture"
image="https://www.ucd.ie/sportandfitness/t4media/Banner---PT-Course.jpg" />
</CardContent>
</div>
<p>Hello</p>
</Card>
</Grid>
</Grid>
</Paper>

</Container>

关于javascript - 在大屏幕上使 material-ui 网格环绕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58606330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com