How to set image size relative to parent height with CSS?

Spread the love

To set image size relative to parent height with CSS, we set the width to auto.

For instance, we write

a.image_container img {
  width: auto;
  height: 100%;
}

to set the width of the img element to auto to make it fit the width of the a element with class image_container.

Leave a Reply

Your email address will not be published. Required fields are marked *