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
Post a Comment