メモ用サブブログ

子曰わく學びて時にこれを習う。

ページの内容が短くてもウィンドウ下部にフッターを固定する方法

ページの内容が短い時に、フッターまで上のほうにあがってしまってみっともないことがある。それの回避方法。

html {
  position: relative;
  min-height: 100%;
}

#footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  /* Set the fixed height of the footer here */
  height: 60px;
  background-color: #f5f5f5;
}

htmlに対しmin-height: 100%;position: relative;を設定して、#footerposition: absolute;で固定する。

こうすると内容が短くても長くても、フッターをページ下部に固定することができる。

参考

Sticky Footer Template for Bootstrap