I'm having trouble keeping the 'transform-scale' attribute on an aspect ratio when the browser window is being resized. For instance, if the window was resized, the iframe with the transform-scale attribute would scale the contents inside to fit the iframe width and height without resizing anything of the sites contents. I can't seem to understand how I could achieve this without using JavaScript or any other Libraries. This is what I came up with below:
HTML:
<div>
<iframe id="resize" src="http://www.w3schools.com/" width="100%" height="100%"></iframe>
</div>
CSS:
* {
margin:0;
padding:0;
}
div {
height: 100vw;
width: 56.25vw;
/* 100/56.25 = 1.778 */
background: skyblue;
max-height: 100vh;
max-width: 177.78vh;
/* 16/9 = 1.778 */
margin: auto;
position: absolute;
top:0;
bottom:0;
/* vertical center */
left:0;
right:0;
/* horizontal center */
}
iframe {
-webkit-transform:scale(0.8);
-moz-transform-scale(0.8);
-o-transform: scale(0.8);
-ms-zoom: 0.8;
}
http://jsfiddle.net/rkmyc95e/1/
All I'm trying to do is maintain the 'transform-scale' aspect ratio when the window is scaled.
NOTE: As you can see, I'm also having issues maintaining the aspect ratio of the iframe, I can't maintain the top and bottom to stay in place.