106
91

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

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

Last updated at Posted at 2018-03-06

コンテンツ量が多い時も少ない時も、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;
}

他にもやり方は色々あると思いますが
このやり方だといじる所も少なくて簡単にできました。

106
91
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
106
91

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?