Given the following simple html page body
...
<body>
<div>
...
</div>
<div>
...
</div>
<div style="height:***">
<svg width="100%" height="100%">
...
</svg>
</div>
</body>
let's focus on the last div, which contains an svg element.
If the browser window is resized horizontally, the div width changes automatically with the new size. As a consequence, the svg width follows and the contained drawing scales accordingly. This without any special stilying or javascript responsive code.
If the browser window is resized vertically, on the other hand, neither the div nor the svg height change.
1 - What .css needs to be applied to the div to obtain the same effect vertically?
In other words, the div should resize to an height which exactly (no y overflow) fills the current remaining visible space in the browser window.
As a consequence, the svg would rescale vertically accordingly, which is the desired final effect.
If css is not enough to obtain this effect and javascript is absolutely necessary,
2 - Which event should be hooked, on which element, and what code is needed
to calculate the exact height to assign the the div to have no y overflows (considering previous elements, borders, paddings, margins etc.)?