I'm trying to make a web image gallery for all my photos. And when i click an image i want it to pop up in full screen. I use a container to be able to add the pictures and an exit button.
Is there any way without Javascript to make the picture scale max in all directions, without loosing aspect? A portrait picture for example will at a desktop have a height at 100%, while on phone the width will have too be 100%.
if i add just the picture it will scale right, but inside the container it gets tricky for me.
.container{
margin-top: 1%;
z-index: 20;
margin-left: auto;
margin-right: auto;
position: fixed;
left: 50%;
transform: translate(-50%, 0);
max-height: 95%;
}
.container img {
max-width: 100%;
max-height: 100%;*/
}
<div class="container">
<img src="IMG_9810.jpg" class="imagepopup">
<button class="btn">X</button>
</div>