krow 0 Posted April 8, 2013 Report Share Posted April 8, 2013 (edited) Hello, I'm kind of stuck here. I managed to resize my image with a fixed div max-width of 960px and it actually works nicely as long as you resize it both vertically and horizontally. It also works when you resize the image horizontally keeping the height constant but it doesn't work the other way around. When I resize it vertically then the image gets cut off. I need the image to resize regardless of whether I'm changing the width or the height. I hope it's clear! I'm leaving the code below for more info. Thanks for the help! <!DOCTYPE html><html><head><title>Title of the document</title><style>img {max-width: 100%;height: auto;position:relative;z-index:1000;}#container{max-width:500px}</style></head> <body> <div id="container"><img src="http://4.bp.blogspot.com/-5ZidK4NGC68/TzNOGRrdt8I/AAAAAAAADfU/r7_MCTq0WUA/s1600/Vltava+River,+Prague,+Czech+Republic.jpg" /></div></body> </html> Edited April 8, 2013 by krow Quote Link to post Share on other sites
newseed 26 Posted April 8, 2013 Report Share Posted April 8, 2013 The proper way is to set it using either width or height...not both. Don't use max-width or max-height. Quote Link to post Share on other sites
krow 0 Posted April 8, 2013 Author Report Share Posted April 8, 2013 The proper way is to set it using either width or height...not both. Don't use max-width or max-height. Can you provide an example based on my code? I tried doing what you suggested but I didn't get it to work. Quote Link to post Share on other sites
newseed 26 Posted April 8, 2013 Report Share Posted April 8, 2013 #container img {height: 100px;} Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.