BlobZ Posted May 14, 2020 Share Posted May 14, 2020 I'm trying to force an image to be displayed totally within a viewport maximizing either the width(landscape picture) or height(portrait picture) so that the picture is always fully displayed. Can anyone provide HTML/CSS to achieve this. My pictures are larger than the viewport so always need shrinking. Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted May 14, 2020 Share Posted May 14, 2020 This should work: display: block; max-width: 100vw; max-height: 100vh; width: auto; height: auto; The element containing the image should take up the full size of the window for this to work correctly. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now