Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Leaflet map to height: 100% of container

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

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%;
}
like image 974
Charles Okwuagwu Avatar asked Apr 21 '15 13:04

Charles Okwuagwu


2 Answers

Set

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

and give its container position: relative.

like image 176
James Conkling Avatar answered Sep 19 '22 19:09

James Conkling


The above answer didn't work for me, but this did:

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

..from A full screen leaflet.js map

like image 45
Alex Avatar answered Sep 18 '22 19:09

Alex