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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -