Full full screen ratio
How can I display an image that fills the entire screen (HTML or Javascript) but doesn't stretch or distort, it maintains aspect ratio.
So it will be centered and either:
You have 100% height and width x% (where "x" is less than or equal to 100%)
or
Are y% high and 100% wide (where "y" is less than or equal to 100%)
For something like a full screen web image viewer.
+3
source to share
3 answers
html {
margin: 0;
padding: 0;
}
.container {
max-width: 100%;
}
.img-class {
max-width: 100%;
height: auto;
position: relative;
}
You can set the container div to be exactly positioned on the screen, using absolute position if necessary.
+1
source to share