2017-04-03 12 views
0

Je tente de centrer ma carte google, mais elle ne souhaite pas être alignée à gauche. Chaque fois que j'essaie de le modifier, il supprime mon en-tête.Centre Google map sous le bloc d'en-tête au centre sur la page Web

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

Mon code dans mon 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 [Mes résultats actuels] [1]

Répondre

0

Ajouter position: relative à la règle pour #mapCanvas pour le centrage de la marge automatique gauche/droite au travail.

+0

ne fonctionnait pas. rien n'a changé –

+0

Comment la carte Google entre-t-elle dans cette DIV? Y a-t-il plus de code? (il doit y avoir ...) – Johannes

+0

grâce à une clé API et donnée lat & lng –