I'm trying to do this in CSS and thought it was simple, I've never actually needed to do this before, but now I've tried it I can't get it to work.
I have a container, and in it is an image. What I want is the image to increase in size based on HEIGHT not WIDTH. I thought this would as easy as this:
#project-header {
height: 50%;
}
#project-header img {
display: block;
height: 100%;
width: auto;
margin: auto;
}
This isn't working.
My container is 50% height of the browser window, so this is all fine, but the image displays at its original size.
I expected it to behave as a responsive image would when using width: 100%, height: auto; but my image is ALWAYS its original size (and so flows out of the container) and doesn't adapt to the height of its container.
Am I missing something? Or is this just not possible? Is there a way to do this?