2017-04-03 261 views
0

我試圖居中我的谷歌地圖,但它不想從左對齊移動。每當我嘗試改變它,它會刪除我的標題。中心谷歌地圖下的標題塊中的網頁

我的CSS代碼

#mapCanvas { 
    width: 960px; 
    height: 150px; 
    margin-left: auto; 
    margin-right: auto; 
} 

header { 
    width: 960px; 
    height: 150px; 
    margin-left: auto; 
    margin-right: auto; 
    background-color: #339966; 
    font-family: Garamond; 
    font-weight: bold; 
    font-style: italic; 
} 

h1{ 
    color: white; 
    font-family: Garamond; 
    font-weight: normal; 
    font-style: italic; 
    text-align: center; 
    font-size: 40px 
} 
p { 
    color: white; 
    font-family: Garamond; 
    font-weight: normal; 
    font-style: italic; 
    text-align: center; 
    font-size: 20px; 
} 

我在我的HTML代碼

<body> 
    <header> 
     <h1> 
      Find a user's location using HTML5 Geolocation 
     </h1> 
     <p> If Geolocation sercive is failed, the University of Maryland Campus will be displayed on a map</p> 
     </header> 

    <div id="mapCanvas"> 

    </div> 
</body> 

[1]:https://i.stack.imgur.com/6WZiy.jpg [我目前的成績] [1]

回答

0

添加position: relative#mapCanvas規則左/右自動保證金中心工作。

+0

沒有工作。沒有任何變化 –

+0

Google地圖如何進入DIV?有更多的代碼嗎? (必須有...) – Johannes

+0

通過一個API密鑰,並給出經緯度 –