2016-05-06 12 views
3

Ich habe ein Problem hier, ich möchte den Text #top_page h1 zentrieren, aber es funktioniert nicht und ich weiß nicht warum. Kann jemand Vorschläge machen? Ich habe alles versucht außer text-align: center; und float: rechts oder links funktioniert auch nicht.HTML-Textausrichtung: Mitte; funktioniert nicht

Ich suchte auf Google nach Hilfe und schaute durch die gleichen Fragen auf Stapelüberlauf, aber keiner von ihnen löst das Problem, also bitte ich euch um Hilfe.

body { 
     background: url(img/bg.jpg) no-repeat center center fixed; 
     -webkit-background-size: cover; 
     -moz-background-size: cover; 
     -o-background-size: cover; 
     background-size: cover; 
     display: inline-block; 
     font-family: 'Cabin', sans-serif; 

    } 

    a { 
     text-decoration: none; 
     color: black; 
     font-family: 'Cabin', sans-serif; 
    } 

    li { 
     float: right; 
     margin-top: 3px; 
     margin-right: 50px; 
     color: white; 
     font-family: 'Cabin', sans-serif; 
     font-size: 15px; 
    } 

    header { 
     display: block; 
     position: fixed; 
     top: 0px; 
     left: 0px; 
     width: 100%; 
     height: 50px; 
     background: white; 
     font-family: 'Cabin', sans-serif; 
     z-index: 999999; 
    } 

    a:hover { 
     color: crimson; 
     font-family: 'Cabin', sans-serif; 
    } 

    span { 
     width: 100%; 
    } 

    #top_page h1 { 
     font-size: 80px; 
     color: white; 
     margin-top: 250px; 
     display: block; 
     text-align: center; 
     font-family: 'Cabin', sans-serif; 
    } 

    #top_page h3 { 
     font-size: 40px; 
     margin-top: -40px; 
     color: white; 
     text-align: center; 
     margin-left: 315px; 
     font-family: 'Droid Sans', sans-serif; 
    } 
+2

Können Sie Ihren HTML-Code hinzufügen, damit wir etwas haben können? Brauchen Sie ein [minimales, vollständiges und überprüfbares Beispiel] (http://stackoverflow.com/help/mcve) (MVCE). – timolawl

+0

Fertig editieren der html – Venx

Antwort

3

Ihr Kopf hat 100% Breite, aber der Körper nicht. Füge einfach width: 100% zu body hinzu.

+0

Oh danke! es half: D – Venx

1

Geben Sie Ihrem Körper Element Breite von 100%. Dann geben Sie Ihr div #top_page text-align center.

Verwandte Themen