为页面设置页脚的方法

比如设置一行版权声明,必须居于页面底部。如果页面内容很多,则该页脚被挤到最下;如果页面没有内容,则位于浏览器最下方。


css代码:

html,
body {
  height: 100%;
  /* The html and body elements cannot have any padding or margin. */
}

/* Wrapper for page content to push down footer */
#wrap {
  min-height: 100%;
  height: auto;

/* Negative indent footer by its height; -60px的底部margin,使得下面的元素“叠”或者说“往上拽”60px的距离

如果下面的元素正好是60px的高度,那么就整好占据wrap的底部,也就是说页脚的下边缘正好和wrap的下边缘叠在一起。*/

margin: 0 auto -60px; /* Pad bottom by footer height;虽然上面的样式是的页脚整好占据容器的底部,但是容器的文字足够多时,会和页脚交叠在一起,因此必须留出填充,使得底部的内容只有页脚*/ padding: 0 0 60px; } /* Set the fixed height of the footer here */ #footer { height: 60px; background-color: #f5f5f5; }

你可能感兴趣的:(为页面设置页脚的方法)