LoginSignup
1
0

More than 3 years have passed since last update.

Sticky Footer作ってみる

Posted at

Sticky Footer作ってみる

・メインのコンテンツにflex-grow:1を指定することでコンテンツが足りなくても最大高さまで伸びる

.parent {
    display: flex;
    flex-direction: column;
    height: 100vh;
    color: white;
}

header {
    flex-shrink: 0;
    height: 50px;
    background-color: #EF9912;
}

main {
    flex-grow: 1;
    background-color: #482D1C;
}

footer {
    flex-shrink: 0;
    height: 50px;
    background-color: #5E9C3B;
}
import React from 'react'
import './Hoge.css'

export const Hoge = () => {
    return (
        <>
            <div className="parent">
                <header>header</header>
                <main>
                    main
                </main>
                <footer>footer</footer>
            </div>
        </>
    )
}

結果
スクリーンショット 2020-11-18 23.52.59.png

1
0
0

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
1
0