The image is 100% of the document width. I want the max-height of the image to be 2/3 of the screen height but to retain aspect ratio, and for the image to be centered.
Here is a Fiddle for a starting point.
EDIT: I've updated the fiddle to demonstrate one CSS solution I found (shown below in answers) but it would be preferable to have a solution that has more browser support.
Html:
<header>
<div class="header-content"></div>
</header>
<div class="image-wrapper">
<img class="image" src="http://designyoutrust.com/wp-content/uploads/2013/06/376.jpg" alt="pic" />
</div>
<div class="other-content">
</div>
CSS:
header {
width: 100%;
border: 1px solid black;
box-sizing: border-box;
}
.header-content {
height: 5em;
}
.image {
width: 100%;
}
.other-content {
height: 20em;
width: 100%;
background-color: black;
}
I've just started learning web development so I'm very new to all this. I've tried creating a function that says if image height >= 67vh then html width = image width but I couldn't get it to work.