亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 Material UI Card 和 CardMedia 在背景圖像上添加一些文本

如何使用 Material UI Card 和 CardMedia 在背景圖像上添加一些文本

白衣染霜花 2023-09-18 16:30:43
因此,我使用卡片組件來創建背景圖像,但是,我不確定如何在圖像上添加文本。可能還有更好的方法,我愿意接受其他想法。<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"

  }

}));

https://img1.sycdn.imooc.com//65080ae400015a3b06480140.jpg

查看完整回答
反對 回復 2023-09-18
  • 1 回答
  • 0 關注
  • 113 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號