Is there an equivalent to background-size: cover and contain for image elements?
Solution #1 – The object-fit property (Lacks IE support) Just set object-fit: cover; on the img . body { margin: 0; } img { display: block; width: 100vw; height: 100vh; object-fit: cover; /* or object-fit: contain; */ } <img src=”https://loremflickr.com/1500/1000″ alt=”A random image from Flickr” /> See MDN – regarding object-fit: cover: The replaced content … Read more