The code below showcases a 300*300 px box with a footer that adjusts its height based on the contents of the green box. The content in the green box is editable, allowing users to input text and automatically increase the height of the footer (marked in red).
let img = document.getElementById("img");
img.src = "https://www.svgrepo.com/show/117819/microphone.svg"
document.getElementById("checkbox").onchange = (event) => {
if (event.target.checked) {
img.style = "display: block;"
} else {
img.style = "display: none;"
}
}
.wrapper {
height: 300px;
width: 300px;
outline: solid;
display: flex;
flex-direction: column;
justify-content: flex-end;
font-size: 3em;
}
.footer {
width: 100%;
height: min-content;
outline: solid pink;
display: flex;
}
.child1 {
width: min-content;
height: min-content;
}
.child1>div {
width: 100px;
min-height: 80px;
background-color: green;
}
.child2 {
flex-basis: 100%;
flex-shrink: 1;
flex-grow: 0;
height: 100%;
background-color: red;
display: flex;
justify-content: center;
overflow-x: clip;
}
.child2>img {
height: 95%;
}
<div class="wrapper">
<div class="footer">
<div class="child1">
<div contentEditable></div>
</div>
<div class="child2" contentEditable>
<img src="microphone.svg" id="img" style="display: none;">
</div>
</div>
</div>
<input type="checkbox" id="checkbox">
If you check the box, a large microphone icon will appear within the red box. The challenge is to implement this without affecting the ability of the footer to expand based on the green box's content.
https://i.sstatic.net/I3gMP.jpg
How can I achieve this outcome without disrupting the footer's dynamic resizing behavior according to the green box's content?