I have a dynamic image, sometimes its portrait, sometimes it is landscape. I wish to fit this 100% to it's parent div and still preserve aspect ratio.
I am aware similar questions have been asked before but I have a few stipulations:
Is this possible?
It is not possible to fit image (100%) inside a container and maintain aspect ratio without using background-cover or js. You are providing either a landscape or a portrait image which has to be stretched horizontally or vertically to fit the div 100%.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.