The task is to create a 300x200px rectangle, the top of which ( green ) has an unknown height (according to the height of the content), and the main area ( blue ) occupies the rest of the area of the rectangle both in width and height.
At the same time, the content of the main area can be large both in width and in height, therefore the main area (it is she, and not the whole rectangle!) Should have 2 scrollbars (if necessary).
It should look like this:
Googling on the "div fill remaining height" theme, briskly began to solve the problem, making the display: table container, the main area being display: table-row with height: auto, and in it another div with height: 100%:
<div style="background-color: red; display: table; width: 300px; height: 200px;"> <div style="background-color: green; display: table-row; height: 0;"> Lorem ipsum </div> <div style="background-color: blue; width: auto; display: table-row; height: auto;"> <div style="height: 100%; width: 100%; overflow-y: auto;"> 11111111111111111111111111111111111111111111111111111111111111111111111111<br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> 11 <br> </div> </div> </div> In terms of height, everything is fine.
Why not say about the width. Which, as is clear from the screenshot, comes out not equal to 300px. Rectangle stupidly stretched in width.
It turns out that a div (display: table-row) absolutely doesn’t care about width: 100% in both its ward div, and if you set it to itself.
Although, if fixedly set 300px to the client, and leave the height: auto div (display: table-row), then he understands this.
But all this layout is not a one-time solution somewhere out there, but a flexible thing for centuries, so the option to set height / width somewhere else is not appropriate for me except in the container. And JS for this does not offer - he is here a crutch.
In my head spinning, that the main area must be enclosed in another container. Still in the head table-cell turns. But what-how-where - I'll never know.
I tried everything, but did not achieve anything new.
