gpt4 book ai didi

css - 在 Grid item Material UI 中将图像对齐到中心

转载 作者:行者123 更新时间:2023-12-02 16:47:13 26 4
gpt4 key购买 nike

我正在使用来自 Material UIGrid .我不知道为什么网格元素中的图像向左对齐而不是向中心对齐。

    <Grid container direction="row" justify="center" alignItems="center">
<Grid item xs={6}>
<Grid container direction="row" justify="center" alignItems="center" alignContent="center" style={{minHeight:"200px"}} >
<Grid item xs={12}>
<Typography style={{color:'white', textAlign:'center', fontSize:'2rem'}}>{name}</Typography>
</Grid>
<Grid item xs={6}>
<a href={github} target="_blank">
<img src={githubIcon} width="32px" height="32px" color="white"/>
</a>
</Grid>
</Grid>
</Grid>
</Grid>

同样在 Typography 中,我必须使用 textAlign 才能居中,但如何对齐图像?

最佳答案

尝试为包裹图像的网格提供 container 属性,然后通过添加 justify="center" 和/或 alignItems="使图像居中中心”到这个容器。

关于css - 在 Grid item Material UI 中将图像对齐到中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60079894/

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