Hi, new here. I've built a carousel, and I want the images to max out the screen in one dimension (width if the width of the image is greater than the height, and height if vice versa), and I want them scaled proportionally. At the moment, they are scaling to the width, but they hugely overflow the viewport in the vertical direction.

HTML and CSS in pastebin: https://pastebin.com/dw0b3Mpg