I am working with Ant Design. I want my card cover image to automatically resize and fill the container but I am not able to do so.
Here is an example of what I am trying to achieve.
This is what I am trying to achieve.
The code I am using right now:
<Card
hoverable={true}
size="small"
style={{ width: '200px', backgroundColor: 'transparent'}}
cover={<img alt="images" src={data && data.image} style={imageStyle}/>}
onClick={() => handleCardClick(data) }
bordered={false}
></Card>
I tried multiple approaches to solve this problem such as adding CSS to the image element itself. But didn't got any satisfactory results.
const imageStyle = {
// height: '100%',
backgroundSize: 'cover',
borderRadius: '5px',
backgroundRepeat: 'no-repeat',
backgroundPosition: '50%' }
What I found is that and-design wraps the image element in the ant-card-cover class, I am not sure if this is the culprit but I think this division does not resize accordingly. This is just my guess. Please correct me If I am wrong somewhere or have missed something.