I'm trying to have a div that scales height while keeping the aspect ratio on a responsive landing page. The reason is that I have a background image that needs to stay the same aspect ratio and fill the entire space of the div. If I used 'background-size:cover', it will clip some of the image. If I use 'background-size:100%', it will stretch the image. I don't care about the size of the div as long as the background-image is shown completely.
.myDiv {
width: 100%;
aspect-ratio: 1200/700;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<section class=myDiv "></section>
What happens is the height doesn't fit the aspect ratio, it is only as tall as the content.