How to handle an image in a div container

Help with images:
It seems like I saw in a Pinegrow video where he was putting an image into a div. The image-holding div would control the size of the image.

So the div:
width: 150px
height: auto

The image inside the div:
width: 100%
height: auto
object-fit: cover

So if I make the container div 100 px, it will be 100px x 100px, whereas the image is 100px x 62px, leaving the remaining space underneath and expanding out of the master header container.

Not%20collapsing

Did I interpret that correctly? I have done this today and it worked in one instance and not in another on the same page. In the instance that it did not work, the div containing the image does not collapse around the image as it did in the first one. It extended further vertically below the image. So it seems like something is interfering or maybe I am just looking at the process incorrectly.