I have a dilemma with a div containing multiple elements. My goal is to make the div 100% in width, while also attempting to preserve the aspect ratio if feasible. Should the enclosed elements exceed the div's boundaries, then the height will adjust accordingly.
<div class="wrap">
<div>example text</div>
<img ... />
<span>more text</span>
<div>testing testing</div>
</div>
In my opinion, the CSS code might look something like this:
.wrap {
width: 100%;
min-height: maintain-aspect-ratio; /* striving to keep aspect ratio (2:1) */
height: auto;
}
Has anyone encountered this challenge previously?