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

时间:2015-04-21 13:38:30

标签: twitter-bootstrap-3 height leaflet

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

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

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

2 个答案:

答案 0 :(得分:4)

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

并给它的容器position: relative

答案 1 :(得分:1)

上述答案对我没有用,但确实如此:

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

..来自A full screen leaflet.js map