I have:
<div style="height:15px">
<img src="image" />
</div>
The image is bigger than 15px, so it's outside the div when you see it. How do I "crop" the image (show only the 15px port of it), only using css?
I have:
<div style="height:15px">
<img src="image" />
</div>
The image is bigger than 15px, so it's outside the div when you see it. How do I "crop" the image (show only the 15px port of it), only using css?
You need overflow:hidden
see an example here:
http://www.jsfiddle.net/S8qAq/
Read about overflow
: here W3Schools
Good luck!
overlow: hidden
, object-fit: cover;
and width: fit-content
they come with their own hurdles. If you have more than one image, then these methods may not provide you with the best solution.
Instead, you can define parent element size and force children to fit inside accordingly with max-height
and max-width
<div style="height:15px; width: 15px;">
<img src="image" style="max-height:100%; max-width: 100%;">
</div>