After googling around a bit, I found this
HTML
<div class="divContainer">
<img src="image.png">
<div>
CSS
.divContainer{
width :200px;
height:200px;
border:solid;
}
img{
width: 100%;
height: 100%;
object-fit: contain;
}
This works well but it can only scale until it reaches the native resolution of the original picture and stops scaling with the div container but, I want it to go ahead and upscale beyond its native resolution.
Any ideas?
Change object-fit: contain;
to object-fit: cover;
.
.divContainer {
width: 700px; /* Bigger than image's width. */
height: 500px; /* Bigger than image's height. */
border: solid;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
<div class="divContainer">
<img src="https://dotjpg.co/YfUB.jpg"> <!-- Image Dimensions: 640px x 426px -->
<div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With