The best way is to use the CSS length units vh
and vw
. These allow a block-level HTML element to have a dimension relative to the viewport size, instead of the size of its parent element (as %
does).
e.g.:
#map {
width: 100vw;
height: 100vh;
}
For reference: https://developer.mozilla.org/en-US/docs/Web/CSS/length