JSFiddle - React, Tailwind, and code Playground

HTML

<h3>
 A box with an image that doesn't have a proper height, but had a proper aspect ratio mantained
</h3>
<div class="flex-box-centered">
  <img class="flex-img" src="https://cdn0.vox-cdn.com/thumbor/x4uBPZ7BTfUn6-lSDXEk2gng9Fg=/cdn0.vox-cdn.com/uploads/chorus_asset/file/3752882/crab-interstitial.0.jpg" />
</div>
<h3>
 a box with an image that has a proper height/width of 200px in the same region
</h3>
<div class="flex-box-centered">
  <img class="flex-img" src="https://placehold.it/200x200" />
</div>

CSS

.flex-box-centered {
  display: flex;
  width: 200px;
  height: 200px;
  justify-content: center;
  align-items: center;
  background: #fff;
}

.flex-img {
  display: flex;
  width: 100%;
  height: auto;
}