谷歌地图填充页面保留在标题下方

2024-01-11

我试图使标题 div 出现在 Google 地图上方,但让地图填充页面内容的所有其余部分。

我遇到的问题是页面不断滚动,但我不希望它滚动。它滚动的量与标题高度相同。我尝试将溢出:隐藏,但这不起作用,因为虽然它不再滚动,但它也没有显示谷歌徽标和所需的法律内容。

这是我的html:

<body>
  <header>Title</header>
  <div id="appcontent">
      <div id="map-canvas"></div>
  </div>
</body>

and CSS:

html, body {
  margin: 0px;
  width: 100%;
  height: 100%;
}
#appcontent {
  width: 100%;
  height: 100%;
}
#map-canvas {
  width: 100%;
  height: 100%;
}
header {
  width: 100%;
  height: 40px;
  background-color: #CFCFCF;
}

我已经对我在这里想做的事情做了一个小提琴:http://jsfiddle.net/5LVQX/1/ http://jsfiddle.net/5LVQX/1/

有人能帮我解决这个问题吗?


通过使用绝对定位,像这样(fiddle http://jsfiddle.net/antisanity/5LVQX/2/)

#map-canvas {
    position: absolute;
    top: 40px;
    left: 0px;
    right: 0px;
    bottom: 0px;
}
header {
    position: absolute;    
    top: 0px;
    left: 0px;
    right: 0px;    
    height: 40px;
    background-color: #CFCFCF;
}

See position: absolute https://developer.mozilla.org/en-US/docs/Web/CSS/position#Values.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

谷歌地图填充页面保留在标题下方 的相关文章