I am having some trouble with the code below. What is supposed to happen is the image rests neatly inside the card with some padding around the edges. Instead, it flows out of the parent div.
Code:
<div class="card greeting">
<h3>Good Morning, admin</h3>
<p class = "greeting-text">Mornings are the start of new ideas.</p>
<img src = "<?php echo ASSETS_PATH . 'images/park.png' ?>">
</div>
.card {
border-radius: var(--border-radius);
background-color: var(--page-background-color);
box-shadow: var(--box-shadow);
cursor: pointer;
padding: 8px;
margin: 13px 0;
border: 2px solid transparent;
transition: .3s;
color: var(--font-color);
object-fit: contain;
}
.greeting{
background-repeat: no-repeat;
background-position: right;
background-size: 55px;
padding:10px;
}
.greeting img{
background-repeat: no-repeat;
background-position: right;
background-size: 55px;
padding:10px;
}
.greeting .greeting-text{
word-wrap: break-word;
overflow:hidden;
}
What would be a simple solution for this? My goal is to have the image neatly inside the card.
I have tried object-fit:contain
and other solutions but either I didn't do them correctly, or something else is wrong.