[英]Align image to the center in Grid item Material UI
我正在使用Material UI 中的Grid
。 我不知道為什么 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
來居中,但是如何對齊圖像?
嘗試給 Grid 包裝圖像, container
屬性,然后通過向此容器添加justify="center"
和/或alignItems="center"
來使圖像alignItems="center"
。
將此代碼用於您的網格標簽。
alignContent='flex-start' alignItems='flex-start' justify='flex-start'
我從Material UI文檔Material UI/Grid 中得到了這個
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.