Without this part of the code, the map was not visible →
#map {
width: 90%;
height: 50vw;
margin: auto;
}
height: 50vw; I get this work only through hit and trial. Is there a better way to write this to ensure that it does fit only well in the visible viewport as other code with also occupy viewport?
The current "other" code is not the true reflection of what can be achieved.
This is similar to using vw but like aspect-ratio the height it relative to the element width, not the viewport width, so you could have a max-width set if you wanted.
Percentage padding (and margins) are based on the width of the ‘containing block’ (for both horizontal and vertical padding).
That’s why it can be used for aspect ratio as it has a direct correlation to the width. If it were based on height then there would be no aspect ratio maintained.