Sample on CodePen: http://codepen.io/seadrag0n/pen/oxVJgX
I am learning responsive design without using libraries like bootstrap
and I am facing issue when showing large images in a popup which should be both height and width responsive. I have the following snippet:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.outer {
margin-left: auto;
margin-right: auto;
max-width: 1200px;
border: 1px solid #333;
position: relative;
top: 50%;
}
.inner {
width: 100%;
height: auto;
position: absolute;
}
.inner img {
max-width: 100%;
height: auto!important;
position: absolute;
}
<div class="outer">
<div class="inner">
<img src="http://www.cameraegg.org/wp-content/uploads/2015/06/Sony-RX100-IV-Sample-Images-2.jpg" />
</div>
</div>
Using the above markup, the image is width
responsive but it not height
responsive and in screens of 1920 x 1080
resolution the image looks fine but when I switch to a 1366 x 768
resolution, the image overflow instead of adjusting to the screen size. How can I solve this?
I want to achieve the same styling as it is done in this plugin, if you keep width the same and reduce height of the browser window, the image adjusts to the screen size even though the width is the same.