I loaded Google Maps API v3 and print Google Map in div
. But when set width & height to 100% and auto I can't see the Map.
Here is HTML code snippet.
<!-- Maps Container -->
<div id="map_canvas" style="height:100%;width:100px;margin:0 auto;"></div>
Is there a way to fix this issue?
If that
div
is the only thing on your page, set:I struggled a lot to find the answer.
You don't really need to do anything with body size. All you need to remove the inline style from the map code:
remove all the inline style and add class or ID and then style it the way you like.
You have to set all parent containers to a 100% width if you want to cover the whole page with it. You have to set an absolute value at width and height for the #content div at the very least.
Setting Map Container to position to relative do the trick. Here is HTML.
And Simple CSS.
Tested on all browsers. Here is the Screenshot.
This Work for me.
If you can't affect your parents elements (like in a nested components situation) you can use
height: 100vh
which will make it a full window (=view) height;