positioning a mapbox/leaflet map inside a container div

后端 未结 2 748
猫巷女王i
猫巷女王i 2021-02-08 14:55

I am working with Mapbox in a Ruby on Rails app. For the life of me, I cannot get the map to adhere to any simple CSS. The only CSS that allows the map to appear is giving it an

2条回答
  •  庸人自扰
    2021-02-08 15:06

    Just change the 'position:absolute' to 'position:relative' for both divs:

    #map-container { position: relative; height: 180px; width: 600px; } #map { position: relative; height: inherit; width: inherit; }

    Note: The height and width on the '#map' element will be inherited by the parent div '#map-container', which will be '180px' and '600px' respectively in this case or whatever you set.

    DEMO: http://plnkr.co/edit/qjIAiud3aUF11iQPDKj0?p=preview

提交回复
热议问题