+ -
当前位置:首页 → 问答吧 → 3列布局 auto问题

3列布局 auto问题

时间:2011-07-22

来源:互联网

大家好 问个问题如下:

比如我有个页面:
<div style="margin-left:auto;margin-right:auto;width:900px;height:auto;">
  <div style="float:left;width:300px;background-color:red;height:auto;">
  ccccc<br/><br/><br/><br/><br/><br/><br/><br/>
  </div>

  <div style="float:left;width:300px;background-color:blue;height:auto;">
  bbbb<br/><br/><br/>
  </div>
  
  <div style="float:left;width:300px;background-color:green;height:auto;">
  aaaa<br/><br/><br/>
  </div>
</div>

<div id="footer" style="height:100px;background-color:pink;">

</div>

我想实现的效果是中间3列布局 footer 显示在页面底下 可是以上代码footer显示在页面顶部 感到不解 请大侠指教!

作者: Brokenfango   发布时间: 2011-07-22

<div style="margin-left:auto;margin-right:auto;width:900px;height:auto;">
  <div style="float:left;width:300px;background-color:red;height:auto;">
  ccccc<br/><br/><br/><br/><br/><br/><br/><br/>
  </div>

  <div style="float:left;width:300px;background-color:blue;height:auto;">
  bbbb<br/><br/><br/>
  </div>
  
  <div style="float:left;width:300px;background-color:green;height:auto;">
  aaaa<br/><br/><br/>
  </div>
</div>
<div style="clear:both;"></div>

<div id="footer" style="height:100px;background-color:pink;">

</div>

作者: hongmei85   发布时间: 2011-07-23

footer清除一下浮动就行了。

作者: Acesidonu   发布时间: 2011-07-23

需要在footer层前面清除浮动:
......
<div style="clear:both"></div>
<div id="footer" style="height:100px;background-color:pink;">

作者: dalmeeme   发布时间: 2011-07-23

没错 谢谢各位!

作者: Brokenfango   发布时间: 2011-07-23