在容器内水平对齐3divs

时间:2014-05-08 06:48:56

标签: html css alignment containers center

如何将div容器水平对齐并在其中对齐css中的3个div? 请参阅我的概念:http://postimg.org/image/9el748gst/

   <div id="container">
           <div id="header"> HEADER </div>
           <div id="content"> CONTENT </div>
           <div id="footer"> FOOTER </div> 
   </div>

很抱歉,如果我发帖,我就找不到正确的方法。 谢谢!

1 个答案:

答案 0 :(得分:0)

大概你可以使用这样的东西

演示http://jsbin.com/zuxunavi/1/

HTML

<div id="container">
  <div id="header"> HEADER </div>
  <div id="content"> CONTENT </div>
  <div id="footer"> FOOTER </div> 
</div>

CSS

#container{
  min-height:100px;
  height:auto !important;
  width:100%;
  margin:0 auto;
  background:#CCC;
  padding:5px;
  overflow:auto
}

#header{
  height:50px;
  background:#FF0000;
  width:95%;
  margin:2.5%;
}
#content{
  height:200px;
  background:#25AAE2;
  width:95%;
  margin:2.5%;
}

#footer{
  height:50px;
  background:#8CC63E;
  width:95%;
  margin:2.5%;
}

您可以将此作为参考来开发自己的html页面。希望这会有所帮助。