As I delve into learning CSS, I keep stumbling upon solutions that are almost there for what should be a simple task. Being at a very basic stage of my learning journey, I am struggling with figuring things out.
My current challenge involves placing one image on a page in a horizontal and vertical center alignment. The image should be contained within a div
that occupies 80% of the window height and width. Additionally, I want the image to automatically stretch to fill either the height or width of the div
, depending on which dimension is smaller.
While this may seem straightforward to many, it is quite puzzling for me as a beginner. Any guidance on how to achieve this would be greatly appreciated.
To better illustrate my point, I have created an example: