2017-04-07 45 views
0

我只想嵌入我的谷歌地圖位置。當我使用iframe時,它會達到100%的高度。當我設定高度時谷歌地圖iframe集高度?

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

看起來就是這樣。 enter image description here

地圖大小看起來不錯,但它使用頁腳之間不需要的空白。這是我的ifrmae

<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; 
} 

我只是想表明只有30地圖的大小%。我如何存檔?

回答

4

因爲您使用「padding-bottom:77.4%;」,您正在獲取空白區域。只要使用身高:30%;.

+1

你也可以使用heigth:30vh;它佔用用戶設備屏幕高度的30%。 – Nieck

+0

啊我沒注意到。謝謝! – Janath