css sets the height of the outer container to height or the maximum height max-height
Then set overflow:auto; a scroll bar will appear beyond the height.
You can also use JS to compare the height of the loaded container with the height of the container you need to refer to. When the conditions are met, JS controls the height or maximum height of the outer container, and then overflow:auto;
I don’t know if that’s what you mean.