I am trying to get up to speed on using the Flexbox.
What I want to do is have a navigation panel on the left and a dynamic area on the right.
There is an issue with the dynamic area. The image does not constrain itself to the expected area, and so it overlays the Audio element.
How do I make the image constrain itself to the area that it should in the flexbox?
There could be multiple images and controls in the dynamic panel, so I want them all to fit within the expected area.
.myContainer {
outline: 5px dotted green;
height: 88vh;
display: flex;
gap:25px;
padding:25px;
}
.doOutline{
outline: 1px dotted green;
}
.innerContainer{
display:flex;
flex-direction:column;
}
<div class="myContainer">
<div class="doOutline" style="width:150px;"><p>Fixed Width Nav Panel</p></div>
<div class="doOutline innerContainer">
<audio controls src="https://aitutorcdn.blob.core.windows.net/images/BirdChirping.mp4"></audio>
<img src="https://aitutorcdn.blob.core.windows.net/images/BirdChirping.jpeg">
</div>
</div>
2
Answers
You could explicitly set the width and height of the image to 100%.
This could, however, cause the image to become distorted if the aspect ratio is changed:
Unfortunately, this still covers up the audio player. You could move the image to the background:
Here is the updated code, you can add properties like this to adjust the image.
reference: https://www.geeksforgeeks.org/how-to-auto-resize-image-in-css-flexbox-layout-and-keeping-aspect-ratio/
Click here:
here is the updated css