JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div class="image-container">
<img src="https://via.placeholder.com/500" alt="image">
</div>
</body>
CSS
.image-container {
height: 100px;
width: 100px;
border: 5px solid red;
/*
without this the image will use it's original size,
it'll go outside of the flow of elements
and no longer respect the width: 100% set on img below
it'll be relative to the root of the page (html)
*/
position: relative; /* remove this to check */
}
.image-container img {
position: absolute;
width: 100%;
}