2016-10-18 87 views
-2

我的臉譜,推特和Instagram按鈕重疊。我希望他們坐在邊界上,不要重疊。另外,如何將嵌入式Google地圖與中心對齊?HTML元素互相重疊(+對齊嵌入的Google地圖)

Codepen

body { 
 
    margin: 0px; 
 
    padding: 0px; 
 
} 
 
.banner { 
 
    width: 100%; 
 
} 
 
.navbar { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    overflow: hidden; 
 
    background-color: #333; 
 
    margin-top: -5px; 
 
} 
 
body { 
 
    margin: 0px; 
 
    padding: 0px; 
 
} 
 
.banner { 
 
    width: 100%; 
 
} 
 
.navbar { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    overflow: hidden; 
 
    background-color: #444; 
 
    margin-top: -5px; 
 
} 
 
.navli { 
 
    float: left; 
 
    width: 25%; 
 
    margin-top: 0px; 
 
} 
 
.navli a { 
 
    display: block; 
 
    color: white; 
 
    text-align: center; 
 
    padding: 14px 0px; 
 
    text-decoration: none; 
 
} 
 
.navli a:hover:not(.active) { 
 
    background-color: #333; 
 
} 
 
.activeNav { 
 
    background-color: #000; 
 
} 
 
.navli:last-child { 
 
    border-right: none; 
 
} 
 
.email-block { 
 
    float: left; 
 
    margin-left: 5%; 
 
} 
 
.social-block { 
 
    float: right; 
 
} 
 
.clearfix:after { 
 
    visibility: hidden; 
 
    display: block; 
 
    font-size: 0; 
 
    content: " "; 
 
    clear: both; 
 
    height: 0; 
 
} 
 
.textcenter { 
 
    text-align: center; 
 
} 
 
a { 
 
    text-decoration: none; 
 
} 
 
.links { 
 
    padding: 5px; 
 
    color: white; 
 
    margin-left: 3%; 
 
}
<img src="https://i.sli.mg/km2FIO.jpg" class="banner" /> 
 

 
<ul class="navbar"> 
 
    <li class="navli"><a class="nava" href="mainPage.html">Home</a> 
 
    </li> 
 
    <li class="navli"><a class="activeNav nava" href="contact.html">Contact</a> 
 
    </li> 
 
    <li class="navli"><a class="nava" href="coffee.html">Flowchart</a> 
 
    </li> 
 
    <li class="navli"><a class="nava" href="menu.html">Menu</a> 
 
    </li> 
 
</ul> 
 

 
<h1 style="text-align:center;"><u>Contact</u></h1> 
 
<div class="clearfix"> 
 
    <div class="email-block"> 
 
    <p>email: [email protected]</p> 
 
    </div> 
 
    <div class="social-block"> 
 
    <a href='#' class='links' style="background-color:#3b5998;">Facebook</a> 
 
    <br /> 
 
    <a href='#' class='links' style="background-color:#4099FF;">Twitter</a> 
 
    <br /> 
 
    <a href='#' class='links' style="background-color:#125688;">Instagram</a> 
 
    </div> 
 
</div> 
 
<div class="textcenter"> 
 
    <p>125 Sydney Road, Brunswick, Melbourne, Australia, Oceania, Earth, Solar System, Milky Way, Local Group, Virgo Supercluster, Laniakea Supercluster, Universe</p> 
 

 
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
 
    <div style="overflow:hidden;height:500px;width:84%;"> 
 
    <div id="gmap_canvas" style="height:500px;width:84%;"> 
 
     <style> 
 
     #gmap_canvas img { 
 
      max-width: none!important; 
 
      background: none!important 
 
     } 
 
     </style><a class="google-map-code" href="http://www.themecircle.net/wordpress-ecommerce/" id="get-map-data">Duck Duck Grouse</a> 
 
    </div> 
 
    </div> 
 
    <script type="text/javascript"> 
 
    function init_map() { 
 
     var myOptions = { 
 
     zoom: 16, 
 
     center: new google.maps.LatLng(-37.774684, 144.96065299999998), 
 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
 
     }; 
 
     map = new google.maps.Map(document.getElementById("gmap_canvas"), myOptions); 
 
     marker = new google.maps.Marker({ 
 
     map: map, 
 
     position: new google.maps.LatLng(-37.774684, 144.96065299999998) 
 
     }); 
 
     infowindow = new google.maps.InfoWindow({ 
 
     content: "<b>Duck Duck Grouse</b><br/>125 Sydney Road<br/> Melbourne" 
 
     }); 
 
     google.maps.event.addListener(marker, "click", function() { 
 
     infowindow.open(map, marker); 
 
     }); 
 
     infowindow.open(map, marker); 
 
    } 
 
    google.maps.event.addDomListener(window, 'load', init_map); 
 
    </script> 
 
</div>

回答

0

對於您可以添加line-height:28px;.links CSS鏈接。

的谷歌地圖比對工作,如果你改變了

<div style="overflow:hidden;height:500px;width:84%;"> 
<div id="gmap_canvas" style="height:500px;width:84%;"> 

<div style="overflow:hidden;height:500px;width:84%;margin:auto;"> 
<div id="gmap_canvas" style="height:500px;width:100%;"> 
+0

你的救星,夥計! – CodingDucky

0

.links添加display:block並取出一個標籤之間<br>

0

的社會聯繫,應該是display: inline-block

.social-block a 
{ 
    display: inline-block; 
} 

而且地圖#gmap_canvas的父母應該有一個自動保證金

<div style="overflow:hidden;height:500px;width:84%; margin: auto;"> 

爲什麼有家長和地圖的84%的寬度?也許最好將#gmap_canvas設置爲100%寬度。由於它是一個塊元素,只需刪除width: 84%

http://codepen.io/anon/pen/ALJqrE