Skip to content

Instantly share code, notes, and snippets.

@ichiroku11
Created January 22, 2018 07:06
Show Gist options
  • Select an option

  • Save ichiroku11/30a01c982f19e34b5132992b103900de to your computer and use it in GitHub Desktop.

Select an option

Save ichiroku11/30a01c982f19e34b5132992b103900de to your computer and use it in GitHub Desktop.
flexboxを使ってフルスクリーン+ヘッダとフッタを固定
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>flexbox</title>
<style>
*,
::before,
::after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
body {
display: flex;
flex-direction: column; /* 子要素を垂直方向に並べる */
min-height: 100vh; /* フルスクリーンにする */
margin: 0; /* リセット(スクロールバーが出ないように) */
}
/* ヘッダは上部に固定 */
header {
background-color: #e0fad2;
height: 50px;
}
/* メインはいっぱいに広げる */
main {
background-color: #f8fbff;
flex: 1; /* flex-growのこと */
}
/* フッタは下部固定 */
footer {
background-color: #d7eafe;
height: 30px;
}
</style>
</head>
<body>
<header></header>
<main></main>
<footer></footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment