2014-11-24 85 views
1

每當我向標題中的第二個div添加標題時,它都會向下移動。我已經看到了這個問題的幾個答案,但目前還沒有任何解決方案,所以這個要麼是不同的,要麼我做錯了。添加標題移動Div

這是我的頭

<div id='header' class='full'> 
    <div id='headerhead' class='full'></div> 
    <div id='headertext' class='full'><h1>Protocol Grean</h1></div> 
    <div id='headerbuttons'></div> 
</div> 

這是四個div的

#header { 
    height: 200px; 
    background-color: green; 
} 
#headerhead { 
    height: 50px; 
    background-color: darkgreen; 
} 
#headertext { 
    padding-left: 50px; 
    height: 100px; 
    font-family: Verdana, Geneva, sans-serif; 
    font-size: 20px; 
    text-transform: uppercase; 
    background-color: pink; 
} 
#headerbuttons { 
    height: 50px; 
    background-color: blue; 
} 

的CSS我需要什麼補充,使的HeaderText不向下浮動?垂直對齊似乎沒有爲我做任何事情,並且絕對位置只是使HeaderButton消失。

回答

2

您需要從h1元素刪除margin

#headertext h1 { 
    margin: 0; 
} 
+0

感謝這個!我發現在headertext的作品中增加了'display:inline-block;',儘管我更喜歡這個選擇。 – 2014-11-25 16:28:30