将传单地图设置为高度:容器的100% [英] Set Leaflet map to height: 100% of container

查看:142
本文介绍了将传单地图设置为高度:容器的100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Please how can we set the map div to be height: 100% of its container?

我已经在Bootstrap模板内容部分尝试过此操作,但是我得到的只是高度0px.甚至Google-Dev工具也显示#map高度为0px.

I have tried this within a bootstrap template content section, but all I get is height of 0px. Even Google-Dev tools shows #map height as 0px.

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

推荐答案

设置

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

并为其提供容器position: relative.

这篇关于将传单地图设置为高度:容器的100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆