Considering the following structure of the Document Object Model...
<div id="outer-container">
<div class="side-panel"><div width="200px"/></div>
<div id="content"><!-- some content --></div>
<div class="side-panel"><div width="100px"/></div>
</div>
And with these specified CSS rules...
#outer-container {
display: 'flex';
align-items: 'stretch';
width: '100vw';
height: '100vh';
}
.side-panel {
flex-shrink: 0;
}
#content {
display: 'flex';
flex-direction: 'column';
align-items: 'stretch';
flexGrow: 1;
}
Is there a way to monitor changes in the width/height of #content
?
Typically, this involves observing mutations in the style
attribute and verifying the element's dimensions when the style is altered. However, as it is a child within a flex container, checking the width/height attributes reveals them undefined.
Mutations to the size of #content
do not trigger events from my MutationObserver (configured with
{attributes: true, attributeFilter: ['style']}
) as expected.
The objective is to convert the side panels into drawers once the width of #content
falls below a certain limit. I am using React
, but this issue seems to be more JavaScript/html-related.
Any assistance would be greatly appreciated!
PS: I attempted setting flex-basis
on #content
to the predefined threshold, with no success. Should I define a specific width
instead of utilizing flex-basis
? Uncertain if this might lead to unintended flex behavior.