I have a full screen google map application with a navbar on the top.
So i have a setup like this:
<div class="navbar">
<nav bar stuff......>
</div>
<div id="mapcanvas"></div>
with the mapcanvas element having height and width to be 100%.
However, the mapcanvas seems to overflow out the page and the the entire page could scroll down the page by the amount of the navbar.
How would i go about fixing that?
In the below example, applying style="height: 100%;" to the body and html makes google maps full height because the div the map loads in to is a child of body . In your case, you need to add style="height: 100%;" to the relevant parent elements of #map .
You can also add Google Maps to your site's widget section, like the sidebar or footer. To start, head over to Appearance » Widgets from your WordPress admin panel. Next, click the '+' button and add the 'AIOSEO Local – Map' widget block where you'd like to display your location.
Maybe try adding navbar-fixed-top
to your navbar class.
<div class="navbar navbar-fixed-top">
<nav bar stuff......>
</div>
If you don't want the navbar to be over the map set the #mapcanvas
as this (works till IE7 - haven't tried ie6)
html,body {width:100%;height:100%;margin:0;padding:0;}
#mapcanvas {
background:red;display: block;
position:absolute;
height:auto;
bottom:0;
top:0;
left:0;
right:0;
margin-top:50px; /* adjust top margin to your header height */
}
<div id="mapcanvas">asdf</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With