ドロワーメニュー備忘録

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無題ドキュメント</title>
<link rel="stylesheet" type="text/css" href="http://um-corporation.com/css/reset.css">
<style>
/*ヘッダーまわりはご自由に*/

header {
	padding: 10px;
	background: skyblue;
}
#nav-drawer {
	position: relative;
}
/*チェックボックス等は非表示に*/
.nav-unshown {
	display: none;
}
/*アイコンのスペース*/
#nav-open {
	display: inline-block;
	width: 30px;
	height: 22px;
	vertical-align: middle;
}
/*ハンバーガーアイコンをCSSだけで表現*/
#nav-open span, #nav-open span:before, #nav-open span:after {
	position: absolute;
	height: 3px;/*線の太さ*/
	width: 25px;/*長さ*/
	border-radius: 3px;
	background: #555;
	display: block;
	content: '';
	cursor: pointer;
}
#nav-open span:before {
	bottom: -8px;
}
#nav-open span:after {
	bottom: -16px;
}
/*閉じる用の薄黒カバー*/
#nav-close {
	display: none;/*はじめは隠しておく*/
	position: fixed;
	z-index: 99;
	top: 0;/*全体に広がるように*/
	left: 0;
	width: 100%;
	height: 100%;
	background: black;
	opacity: 0;
	transition: .3s ease-in-out;
}
/*中身*/
#nav-content {
	overflow: auto;
	position: fixed;
	top: 0;
	left: 0;
	z-index: 9999;/*最前面に*/
	width: 90%;/*右側に隙間を作る*/
	max-width: 330px;/*最大幅*/
	height: 100%;
	background: #fff;/*背景色*/
	transition: .3s ease-in-out;/*滑らかに表示*/
	-webkit-transform: translateX(-105%);
	transform: translateX(-105%);/*左に隠しておく*/
	background: rgba(0,0,0,0.3);
}
/*チェックが入ったらもろもろ表示*/
#nav-input:checked ~ #nav-close {
	display: block;/*カバーを表示*/
	opacity: .5;
}
#nav-input:checked ~ #nav-content {
	-webkit-transform: translateX(0%);
	transform: translateX(0%);/*中身を表示*/
	box-shadow: 6px 0 25px rgba(0,0,0,.15);
}
</style>
</head>

<body>
<header>
  <div id="nav-drawer">
    <input id="nav-input" type="checkbox" class="nav-unshown">
    <label id="nav-open" for="nav-input"><span></span></label>
    <label class="nav-unshown" id="nav-close" for="nav-input"></label>
    <div id="nav-content">
    	<p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
        <p style="margin:10% 0;">ここに中身を入れる</p>
    </div>
  </div>
</header>
</body>
</html>