JSFiddle - React, Tailwind, and code Playground

HTML

<h2>
  Using img and div
</h2>

<div class="flex-container">
  <img src="https://www.nicepng.com/png/full/335-3353016_delivery-van-icon-blue-.png" class="img-1">
  <div class="box-1">Img is 50% of container, even though this box's width is double the width of the image (100%)</div>
</div>

<h2>
  Using 2 divs
</h2>

<div class="flex-container">
  <div class="box-2">
    <img src="https://www.nicepng.com/png/full/335-3353016_delivery-van-icon-blue-.png" class="img-2">
  </div>
  <div class="box-1">Img is now half the width of this box, as expected (as width=50% of the img is half of this box's width of 100%)</div>
</div>

CSS

.flex-container {
  display: flex;
}

.img-1 {
    width: 50%;
    border: 1px solid red;
}

.box-1 {
   width: 100%;
   background-color: lightblue;
}

.box-2 {
  width: 50%;
}

.img-2 {
  width: 100%;
  border: 1px solid red;
}