将div保持到页面底部说的是,页面内容满屏和不满屏都在底部,采用js是最常用的方法,但如果能用纯css解决最好了,有网上找了半天,还是有强人的,方法如下:

HTML结构:

<body>
<div >
   <div ></div>
   <div ></div>
   <div ></div>
</div>
</body>

CSS样式:

html,
body {
   margin:0;
   padding:0;
   height:100%;
   _height:100%; /* IE6 hack */
} 
#container { 
  min-height:100%; 
  position:relative; 
} 
#header { 
  background:#ff0; 
  padding:10px; 
} 
#body { 
  padding:10px; 
  padding-bottom:60px; /* Height of the footer */
}
#footer {
   position:absolute; bottom:0; 
   width:100%; 
    height:60px; /* Height of the footer */ 
   background:#6cf; 
}

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-14
  • 2021-06-02
  • 2021-09-19
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案