2013-05-14 61 views
-1

我有這兩個div,並且希望將其中一個放在另一個div的中間。任何幫助,將不勝感激。如何將div放在另一個div內

<div class="PicturesBackground" style="height:350px; width: 100%; background: green; border-radius:15px;"> 
<div class="ContentArea" style="height:80%; width:90%; background: blue; margin-top:30px"></div></div> 

我一直在使用邊距和填充嘗試和它把利潤/填充在整個事情,而不是僅僅的含量 - 面積DIV中日背景股利。

+3

嗨凱文,請永遠記得谷歌第一。 '如何將div放在另一個div中可以給出很多很好的答案,包括[this](http://stackoverflow.com/questions/114543/how-to-center-a-div-in-a-div-horizo​​ntally )高度upvoted堆棧溢出問題。謝謝! – 2013-05-14 14:47:21

+0

可能重複的[如何在另一個div中居中div?](http://stackoverflow.com/questions/11924553/how-to-center-div-within-another-div) – Lowkase 2013-05-14 14:48:55

回答

0

你看這個:

.ContentArea{ 
    margin-left: auto; 
    margin-right: auto; 
} 
+0

它居中水平如何,我會中心這個盒子是垂直的嗎?邊距:汽車;和margin-right:auto;不會改變任何東西。 – ThatOneGuy 2013-05-14 14:55:20

-1

嘗試this

margin: 30px auto; 

希望這有助於!