2016-06-27 22 views
0

在此live page地图看起来很不错,除非您在较小的设备上缩小尺寸以查看550px以下的尺寸。这是我为该部分的代码。我需要更改哪些内容才能显示移动设备或较小设备的地图?谢谢响应地图不显示在550px以下

.columns 
 
{ 
 
    width:100%; 
 
} 
 
.left 
 
{ 
 
    float:left; 
 
    width:460px; 
 
    
 
} 
 
.right 
 
{ 
 
    margin-left:500px; 
 
} 
 
.clear 
 
{ 
 
    clear:both; 
 
} 
 
.google-maps { 
 
    position: relative; 
 
    padding-bottom: 75%; // This is the aspect ratio 
 
    height: 0; 
 
    overflow: hidden; 
 
} 
 
.google-maps iframe { 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    width: 100% !important; 
 
    height: 100% !important; 
 
}
<div class="columns"> 
 
    <div class="left"> 
 
<p><b>Pebble Cove Motel</b></p> 
 
<p>741 Ocean Blvd</p> 
 
<p>Rye, NH 03870</p> 
 
<p><a href="mailto:[email protected]">[email protected]</a></p> 
 
<p>Phone: <a href="tel:6034368108">603-436-8108</a></p> 
 
</div> 
 
    <div class="right"> 
 
<div class="google-maps"> 
 
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d186637.02907792313!2d-70.85793188067471!3d43.037147979147306!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89e2c0b2dad571d3%3A0xf0f66f2f40db8717!2sPebble+Cove+Motel!5e0!3m2!1sen!2sus!4v1463168351650" width="450" height="450"></iframe> 
 
</div> 
 

 
</div></div> 
 
<div style="clear:both;"></div>

回答

0

问题是巨大的margin-left.right导致它缩小。

使用媒体查询以仅使用特定视口宽度以上的浮动布局。我添加了一个到你的CSS。您可以调整min-width的值以满足您的需求。这会将您的物品堆放在较小的屏幕上。

.columns 
 
{ 
 
    width:100%; 
 
} 
 
@media only screen and (min-width: 800px) { 
 
    .left 
 
    { 
 
     float:left; 
 
     width:460px; 
 
    } 
 
    .right 
 
    { 
 
     margin-left:500px; 
 
    } 
 
} 
 
.clear 
 
{ 
 
    clear:both; 
 
} 
 
.google-maps { 
 
    position: relative; 
 
    padding-bottom: 75%; // This is the aspect ratio 
 
    height: 0; 
 
    overflow: hidden; 
 
} 
 
.google-maps iframe { 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    width: 100% !important; 
 
    height: 100% !important; 
 
}
<div class="columns"> 
 
    <div class="left"> 
 
<p><b>Pebble Cove Motel</b></p> 
 
<p>741 Ocean Blvd</p> 
 
<p>Rye, NH 03870</p> 
 
<p><a href="mailto:[email protected]">[email protected]</a></p> 
 
<p>Phone: <a href="tel:6034368108">603-436-8108</a></p> 
 
</div> 
 
    <div class="right"> 
 
<div class="google-maps"> 
 
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d186637.02907792313!2d-70.85793188067471!3d43.037147979147306!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89e2c0b2dad571d3%3A0xf0f66f2f40db8717!2sPebble+Cove+Motel!5e0!3m2!1sen!2sus!4v1463168351650" width="450" height="450"></iframe> 
 
</div> 
 

 
</div></div> 
 
<div style="clear:both;"></div>

+0

谢谢你,这让我疯狂 – mlegg

0

这是你的div。左的宽度。您应该以%为单位制作.left和.right的宽度。类似.left {width:50%;} .right {width:50%;}。

+0

没有工作,我想这也必须是与谷歌的地图CSS – mlegg

+0

好吧,试试这个:{。左浮动:无;宽度:100%;} .right {float:none; width:100%;} @media(min-width:768){.left {float:left;宽度:50%;} .right {float:left; width:50%;}} – Vcasso

+0

当它更小时https://s31.postimg.org/n8tah9a63/Capture2.png有效,但当它更宽时,不是像最初一样的2列https://s31.postimg.org/s7pj3yoob/Capture1.png这应该看起来像宽屏幕https://s32.postimg.org/dmzrod5r9/correct.png – mlegg