I was provided an answer yesterday about how to maintain a responsive box that never overflows its viewport.
CSS responsive box that maintains aspect ratio but NEVER overflows the viewport
However I've never run into another problem, I'm trying to place an image within the container and unfortunately all attempts to resize the image to fit the dynamic container using variations of object-fit:, width: & max-width:, do not work.
Could someone please help me with how I might place an image that Is contained within and occupies 100% of the width of the responsive container. thanks in advance - CES
:root{
--varWidth: 80vw;
--varHeight: calc(80vh + 3.5vh);
}
.aspectRatio3x2 {
--varAspectRatio: calc( 3 / 2);
--varCalcHeight: min(calc(var(--varWidth) / var(--varAspectRatio)), var(--varHeight));
height: var(--varCalcHeight);
width: calc(var(--varCalcHeight) * var(--varAspectRatio));
background-color: gold;
}
.imgMain, .imgOther {
object-fit: contain;
width:100%;
max-width:100%;
border: 2px solid hsla(0, 0%, 100%, .15);
}
.imgMain{
border-bottom: none;
}
/* Other CSS */
.contentContainer {
width: 100%;
height: auto;
padding: min(4vh, 3.5vw);
background: hsl(0 0% 10%);
background:red;
}
.pageDefault {
width:100%;
background-color: black;
}
.pageDefault article {
position: relative;
margin: 0 auto;
background: lime;
}
<div class="contentContainer">
<main id="idMainContent" class="pageDefault">
<article class="aspectRatio3x2">
<figure class="">
<picture class="">
<img class="imgMain" src="../../images/3x2.jpg" />
</picture>
<figcaption></figcaption>
</figure>-->
</article>
</main>
</div>