'Div aspect ratio as minimum height
I have a div that needs to have an aspect ratio if the image is taller than the aspect ratio, but where the height is dependant on the image if the image is wider than the aspect ratio.
An explanation in CSS is shown in the below. I know the CSS below is unrealistic in this case, it's just a way for me to explain what I need better.
If the image is taller than the aspect ratio I would need this CSS:
div {
aspect-ratio: 16/9;
}
If the image is wider than the aspect ratio, I would need this CSS:
div {
width: 100%;
height: auto;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
