将 Google Maps Container DIV 宽度和高度设置为 100% [英] Set Google Maps Container DIV width and height 100%

查看:34
本文介绍了将 Google Maps Container DIV 宽度和高度设置为 100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加载了 Google Maps API v3 并在 div 中打印了 Google 地图.但是当设置宽度 &高度为 100% 和自动我看不到地图.

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.

这是 HTML 代码片段.

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?

推荐答案

如果你想用它覆盖整个页面,你必须将所有父容器设置为 100% 宽度.您必须至少为 #content div 设置宽度和高度的绝对值.

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.

body, html {
  height: 100%;
  width: 100%;
}

div#content {
  width: 100%; height: 100%;
}

这篇关于将 Google Maps Container DIV 宽度和高度设置为 100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆