CardMedia高度材料-ui [英] CardMedia height material-ui

查看:84
本文介绍了CardMedia高度材料-ui的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力更改CardMedia内部图像的高度

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

我通过设置样式

const style = {
  height: 32,
};

并在其中使用

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

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

,但是图像的高度保持不变.唯一发生的是带有标题的叠加层移到顶部.我已经尝试了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

推荐答案

您需要直接在图像上应用样式:

You need to apply the styles on the image directly:

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

设置所需的图像widthheightCard将调整为图像.

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

这篇关于CardMedia高度材料-ui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆