【问题标题】:How to center a element inside material Ui Grid如何在材质 Ui Grid 中居中元素
【发布时间】:2021-03-06 20:49:54
【问题描述】:

我正在尝试在 Material-ui 中将 Grid 内的元素居中,但它不会使项目居中。

<Grid container direction="row" justify="center" alignItems="center">
    <My Element/>
</Grid>

我试过这样,但如下图所示,它不会在边框内居中。

我该如何解决这个问题?

【问题讨论】:

    标签: reactjs material-ui


    【解决方案1】:

    这似乎解决了问题:

    <Grid style={{display: "flex"}} direction="row"  justify='center' alignItems='center'>
       <My Element/>
    <Grid>
    

    【讨论】:

      猜你喜欢
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 2021-01-12
      • 1970-01-01
      • 2020-06-17
      • 2020-10-17
      • 1970-01-01
      • 2020-12-18
      相关资源
      最近更新 更多