1

Trying to wrap an image in a container and have the container always be the dimensions of the child image but the width and height of the container are only resized to the image when the browser is resized horizontally and not when the browser is resized vertically.

I have a demo of the problem here: http://codepen.io/anon/pen/ksDFm

Using display inline-block to wrap the div around the image.

If you load the page and then resize the browsers height but not width the containers width does not change. If you resize the browsers width it works like I would expect. Any way to fix this?

erickreutz
  • 2,779
  • 3
  • 21
  • 18

1 Answers1

-1
please try it

.image-wrap img {
  max-height: 100%;
  width: 100%;
  max-width: 100%; 
  height: auto;
  vertical-align: middle;
}
Mukesh
  • 16
  • This is a very low quality answer. Although your code may solve the problem, please provide an explanation as to why this will fix the question authors problem so everyone can learn from it. – Chris Spittles Jul 17 '14 at 06:16