A have an image and want to be able to zoom it in/out in a scrollable area with fixed size. This is easy, but if the image is smaller than the scrollable area, it should be centered both vertically and horizontally. I can't find a solution how to align it in the middle vertically. Popular solutions like Vertically align an image inside a div with responsive height or How to vertically center a div for all browsers? do not work because of the scrollable area.
http://jsfiddle.net/smvyadnv/9/
HTML
<div class="outer">
<div class="inner small">
<img src="http://lorempixel.com/g/500/300/nature/"></img>
</div>
</div>
<div class="outer">
<div class="inner large">
<img src="http://lorempixel.com/g/500/300/nature/"></img>
</div>
</div>
CSS
img {
width: 100%;
}
.outer {
height: 300px;
width: 400px;
overflow: scroll;
text-align: center;
}
.inner {
display: inline-block;
}
.inner.small {
width: 250px;
height: 150px;
}
.inner.large {
width: 500px;
height: 300px;
}