因此,我使用卡片组件来创建背景图像,但是,我不确定如何在图像上添加文本。可能还有更好的方法,我愿意接受其他想法。<Card> <CardMedia component="img" alt={header.bg_img} src={process.env.API_URL + header.bg_img.url} title="Background Image" /> <CardContent> <h2 className={classes.h2}>{header.title}</h2> <p className={classes.paragraph}>{header.small_description}</p> </CardContent></Card>
1 回答
SMILET
TA贡献1796条经验 获得超4个赞
<Card className={classes.root}>
<CardMedia
component="img"
alt="Contemplative Reptile"
height="200"
image={Header}
title="Contemplative Reptile"
/>
<Typography
gutterBottom
variant="h1"
component="h1"
className={classes.font}
>
Weather
</Typography>
</Card>
const useStyles = makeStyles(theme => ({
root: {
position: "relative"
},
font: {
position: "absolute",
top: "20%",
width: "100%",
textAlign: "center",
color: "black",
backgroundColor: "none",
fontFamily: "Comic Sans MS"
}
}));
- 1 回答
- 0 关注
- 62 浏览
添加回答
举报
0/150
提交
取消