开发者

CSS position - Google Maps Cutoff

Trying to place a header bar at top of a full page Google Map but for some reason it keeps pushing the map below the browser view and cuts off.

If I place the top header (#top) above the map, then position .mapCont to start at top:35px, where #top ends, it pushes the map below the bottom of browser and creates a scroll. Why doesn't it just fit to 100% height regardless of the fixed position layout? It appears to be pushing it 35px below the extents of the browser window.

Cant seem to sort this one out. Thoughts?

Code:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0; padding: 0 }
  #map_canvas { width:100%; height:100%; background: #111 url(../images/loading.gif) no-repeat 50% 50%; z-index: 1; }

.mapCont { 
     display: block;
     height:100%; 
     width:100%; 
     position:fixed;
     top:35px;
     left:0;
     background-color:#111;
     z-index: 0;
}

#top{ 
    height:35px;
    width:100%;
    background: url('../images/finals/wood_top.png') repeat-x;
    display: block;
    position:fixed;
    top:0;
    left:0;
    z-index: 100;
}

.headerLine {
    height:14px;
    width:100%;
    background: url('../images/finals/headerLine.png') repeat-x;
    display: block;
    position:fixed;
    top:31px;
    left:0;
    z-index: 99;
}

</style>

<script type="text/javascript"
    src="http://maps.googleapis.com/maps/api/js?sensor=false">
</script>

<script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElemen开发者_运维问答tById("map_canvas"),
        myOptions);
  }

</script>
</head>
<body onload="initialize()">

<div id="top">  

        <div class="mapCont">
          <div id="map_canvas"></div>
        </div>

</div>
<div class="headerLine"></div>

</body>
</html>


Your calculating 100% + 35px in .mapCont

Have you tried adding overflow:hidden; to the body ?

This works for me: http://jsfiddle.net/SV8VB/


You might try setting your top margin to -35px.

margin-top: -35px;

I had the same problem and a menu bar that was 60px. It appeared as if I was losing about 60px off the bottom so when I tried negative margin the missing bottom content finally showed up. Yours is 35px, so try pushing the map up under the menu and see if that does it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜