CardMedia height material-ui

≡放荡痞女 提交于 2020-01-15 06:17:08

问题


Im struggling trying to change the height of the image inside the CardMedia

Im setting the style with

const style = {
  height: 32,
};

and using it in

<CardMedia
  overlay={<CardTitle title="Title"/>}
  mediaStyle={style}>

  <img src="imgUrl" />
</CardMedia>

but the height of the image remains the same. The only thing that happens is that the overlay with the title moves to the top. I've tried all the CardMedia properties but i havent succeeded


回答1:


You need to apply the styles on the image directly:

<CardMedia overlay={<CardTitle title="Title"/>}>
  <img src={imgUrl} style={style}/>
</CardMedia>

Set desired width and height of the image, Card will adjust to the image.




回答2:


try using style instead of mediaStyle, like

const Style = {
  height: 32,
};

    <CardMedia
      overlay={<CardTitle title="Title"/>}
      style={Style}>

      <img src="imgUrl" />
    </CardMedia>


来源:https://stackoverflow.com/questions/41772257/cardmedia-height-material-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!