html - 谷歌地图iframe设置高度?

标签 html css google-maps iframe

我只想嵌入我的谷歌地图位置。当我使用 iframe 时,它​​的高度为 100%。当我设置高度时

.google-maps iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 30% !important;
}

看起来是这样的。 enter image description here

map 大小看起来不错,但它在页脚之间使用了不需要的空白。这是我的 iframe

<div class="google-maps">
<iframe src="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJ-69Hn5JZ4joRzaymM3Zi2o8&key=AIzaSyDTljbjBpIX73t57vhNIhMKyk0u5p6MNGI" width="600" height="200" frameborder="0" style="border:0">
</iframe>
</div>

.google-maps {
    position: relative;
    padding-bottom: 77.4%;
    height: 0;
    overflow: hidden;
}

我只想显示 map 大小的 30%。我该如何存档?

最佳答案

你得到空白是因为你使用了“padding-bottom: 77.4%;”。只需使用 height: 30%;.

关于html - 谷歌地图iframe设置高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43271984/

相关文章:

javascript - 正文加载 HTML 运行 href 链接

jquery - toggleClass 没有动画

html - "overflow"对这个 <ul> 标签有什么作用?

css - IE显示: table-cell child ignores height: 100%

javascript - 如何在单击时更改背景颜色和字体颜色(无 jQuery)?

ios - 将用户个人资料照片动态映射到iOS中的图钉

html - ng-view 内部的 ng-include 出现 404 问题

javascript - 如何创建 javascript 文件的外部列表

google-maps - 如何获取修改后的drawingManager形状的点坐标?谷歌地图 API v3

java - 在android中找不到JSON解析运行时错误源