Html 如何在另一个div中居中放置div

Html 如何在另一个div中居中放置div,html,css,Html,Css,我有这两个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 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中的ContentArea Div。

这是怎么回事:

.ContentArea{
    margin-left: auto;
    margin-right: auto;
}
尝试:


希望这有帮助

嗨,凯文,请永远记得先用谷歌搜索
如何将一个div集中在另一个div中
给出了很多很好的答案,包括高投票率的堆栈溢出问题。谢谢可能的复制品水平居中,我如何垂直居中?页边顶部:自动;和右边距:自动;不会改变任何事情。
margin: 30px auto;