I have an issue when im trying to make a picture resizable, i explain:
- I have a div "overlay" that will fit the window;
- Inside this div i have another div "imgActive" that will contain some pictures centered on the window;
- Theses pictures inside has to fit the window no matter their size.
But, as you can see on this fiddle the picture inside fit horizontaly (the width change) but when you resize the window vertically, that doesn't resize at all (the height is still the same).
.overlay {
background: rgba(0, 0, 0, 0.7);
height:100%;
position: fixed;
width: 100%;
top: 0;
z-index: 999;
}
.imgActive {
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
left: 50%;
max-height: 100%;
max-width: 100%;
position: absolute;
top: 50%;
z-index: 1000;
}
.imgActive img {
max-height: 100%;
max-width: 100%;
}
What can i do to make it works? To change the height ?
Thanks for your time.
You can use css directly on img. This method maintains the Aspect Ratio of the Picture
Demo
http://jsfiddle.net/ykf6b5ot/
CSS (adjust the min and max % to suit the image size you like)
Or you can use a single class
HTML
CSS
Demo
http://jsfiddle.net/1w9s9wx7/
For the wrapper
imgActive
you do exactly the same as the image CSS and adjust the height/width % you like. 100% is full screenCSS
Demo
http://jsfiddle.net/z69t00ns/