我正在使用来自 Material UI 的 Grid
.我不知道为什么网格元素中的图像向左对齐而不是向中心对齐。
<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/