how to make leaflet map height variable

前端 未结 4 1434
旧巷少年郎
旧巷少年郎 2021-02-03 20:05

In my Application I was making div of map as

but to make my map responsi

4条回答
  •  日久生厌
    2021-02-03 20:26

    You need to set the parent elements to height: 100%; first

    html, body {
       height: 100%;
    }
    

    Demo

    Demo (This won't work as no parent height is defined)

    Explanation: Why do you need to do that? So when you specify an element's height in % then the 1st question that arises is: 100% of what? By default, a div has height of 0px, so 100% for a div simply won't work, but setting the parent elements height to 100%; will work.

提交回复
热议问题