将传单地图设置为高度:容器的 100%

Set Leaflet map to height: 100% of container

请问我们如何将地图 div 设置为高度:其容器的 100%?

我已经在 bootstrap 模板内容部分尝试过这个,但我得到的只是 0 像素的高度。甚至 Google-Dev 工具也将 #map 高度显示为 0px。

body {
    padding: 0;
    margin: 0;
}
html, body, #map {
    height: 100%;
}

设置

#map{
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}

并给出其容器position: relative

上面的答案对我不起作用,但这个答案对我有用:

   body {
        padding: 0;
        margin: 0;
    }
    html, body, #map {
        height: 100%;
        width: 100%;
    }

..来自 A full screen leaflet.js map