css - Make images scale to parent div only when larger, all while using an explicit max-width -


i can make image scale responsively parent div on smaller screens still limit explicit max width:

img {     max-width: 500px;     width: 100%; } 

however, if image smaller parent div, still stretched fill div.

is there way have scale 100% when larger , maintain original dimensions when smaller, without knowing image's dimensions beforehand?

you can set image's max-width: 100%; limit size if it's bigger parent.

img {     height: auto;     max-width: 100%; } 

demo here: http://jsfiddle.net/lmewc/


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -