91
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

footerを常に最下部に固定する方法(簡単)

コンテンツ量が多い時も少ない時も、footerを常に最下部に持ってきたい。
そんな所で結構つまづいてしまったので自分用にメモ。

html・cssの記述は以下

test.html
<body>
  <div id="wrapper">
    <main>

       <!--コンテンツの記述-->

    </main>

    <footer>

       <!--フッターの記述-->

    </footer>
  </div>
</body>
test.css
body,
#wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

footer {
  margin-top: auto;
}

jqueryを使うとか、他にもやり方は色々あると思いますが
このやり方だといじる所も少なく、コピペですぐ実装できるので初心者にもおすすめ。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
91
Help us understand the problem. What are the problem?