gpt4 book ai didi

css - 无法在卡片中居中图像/头像

转载 作者:太空宇宙 更新时间:2023-11-04 00:42:58 30 4
gpt4 key购买 nike

请帮忙,快把我逼疯了,感觉应该这么简单。

我似乎无法在我尝试创建的 Card 组件中将图像/头像居中

尝试了 alignTextalignItemsalignContentjustify

我什至尝试过哪个有效,但显然现在已经过时了......

import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import Typography from '@material-ui/core/Typography';
import Avatar from '@material-ui/core/Avatar';
import Dankirk from '../assets/img/dankirk.jpg'

const useStyles = makeStyles({
card: {
width: "100%",
minHeight: "150px",
borderRadius: "0px",
},
title: {
fontSize: 14,
textAlign: "center"
},
pos: {
marginBottom: 12,
},
avatar: {
margin: 10,
width: 120,
height: 120,
},
});

export default function SimpleCard() {
const classes = useStyles();

return (

<div className={classes.root}>
<div className={classes.container}>
<Card className={classes.card}>
<CardContent style={{justifyContent: 'center'}}>
<Typography className={classes.title} color="textSecondary" gutterBottom>
Test
</Typography>
<Avatar alt="avatarimage" src={name} className={classes.avatar} />
</CardContent>
</Card>
</div>
</div>

);
}

图像只是停留在左边...

最佳答案

你能试试 display flex:

style={{ justifyContent: "center", display: "flex" }}

关于css - 无法在卡片中居中图像/头像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57924153/

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