6

私は CSS を初めて使用し、さまざまな方法を調べましたが、フッターを下部に揃えることができません。何か助けはありますか?ありがとうございました。

.footer {
    position: bottom;
    bottom: -10px;
    height: 30px;
    width: 100%;
    background-color: #171717;
    color: white;
}
4

4 に答える 4

11

位置を固定に変更します。

.footer {
    position:fixed;
    bottom:0px;
    height:30px;
    width:100%;
    background-color:#171717;
    color:white;
}
于 2012-08-31T04:38:57.370 に答える
1

フッターをプッシュできる他のdivなどがある場合に備えて、左のプロパティも追加します

.footer {
    position:absolute;
    bottom:0px;
    left: 0px;
    height:30px;
    width:100%;
    background-color:#171717;
    color:white;
}
于 2012-08-31T04:41:01.863 に答える
1

次のようなものを試してください。

#footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 30px;
    background-color: #171717;
    color: white;
}

これは動作中のライブデモです。

于 2012-08-31T05:39:21.627 に答える
0

Codepen のデモ

HTML:

<div class="header">
  <h2>header</h2>
</div>
<div class="container">
  <h2>container</h2>
</div>
<div class="footer">
  <h2>footer</h2>
</div>

CSS:

body {
  height: 100%;
  width: 100%;
  display: table;
}
html {
  height: 100%;
}
.header {
  background: #f00;
  color:#fff;
  text-align: center;
}
.container {
  text-align: center;
}
.footer {
  background: #ff0;
  text-align: center;
  width: 100%;
  display: table-footer-group;
}
于 2014-10-27T11:39:58.183 に答える