Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>
	<!-- ナビゲーション背景 -->
	<div class="menu-animation-wrapper">
		<div class="js-menu-animated-background"></div>
	</div>

	<!-- ハンバーガーボタン -->
	<a href="#" id="panel-btn" title="メニューを開く"><span id="panel-btn-icon"></span></a>

	<!-- ナビゲーションコンテンツ -->
	<div id="js-nav-overlay">
		<ul>
			<li><a href="#">menu1</a></li>
			<li><a href="#">menu2</a></li>
			<li><a href="#">menu3</a></li>
		</ul>
	</div>
</header>

<p>http://tobiasahlin.com/ のメニューをベースにjQueryを使わないように変更</p>
              
            
!

CSS

              
                // 設定でリセットCSSを読み込んでいる
// https://codepen.io/danielfarias/pen/pmgAy

/* ========================================================
ハンバーガーアイコン
=========================================================*/
#panel-btn {
	position: relative;
	display: block;
	margin: 1rem;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	z-index: 110;
	&:hover{
		background: #F4F4F4;
		transition: 0.5s ease-in-out;
	}

	/* 3本線アイコン用プレースホルダ */
	%btn-icon {
		display: block;
		top: 49%;
		left: 50%;
		width: 24px;
		height: 3px;
		background: #4a4a48;
		z-index: 110;
	}
	/* 3本線アイコン */
	#panel-btn-icon {
		@extend %btn-icon;
		position: relative;
		margin-left: -12px;
		transition: 0.5s;
		/* 上下のライン */
		&:after,
		&:before {
			@extend %btn-icon;
			position: absolute;
			content: "";
			left: 0;
			transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
		}
		&:before {
			margin-top: -8px;
		}
		&:after {
			margin-top: 5px;
		}
	}

	/* 3本線アイコンを×アイコンに変化させる */
	&.menu-active {
		span{
			background: transparent !important;

			&:after,
			&:before {
				margin-top: 0 !important;
			}
			&:before {
				transform: translateY(0px) rotateZ(-135deg);
			}
			&:after {
				transform: translateY(0px) rotateZ(135deg);
			}
		}
	}
}

// #panel-btnクリック後
.menu-active{
	background: #F4F4F4 !important;
}


/* ========================================================
メニューオープン後の下敷き
=========================================================*/
.menu-animation-wrapper {
	overflow: hidden;
	position: fixed;
	width: 100%;
	height: 100%;
	z-index: 100;
	top: 0;
	pointer-events: none;

}
.js-menu-animated-background {
	position: absolute;
	width: 800px;
	height: 800px;
	background-color: #4a4a48;
	border-radius: 50%;
	pointer-events: none;
	transform: scale(0, 0);
	z-index: 101;
	top: -400px;
	left: -400px;

}

// ナビゲーションコンテンツ用
#js-nav-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 102;
	opacity: 0;
	color: #fff;
	pointer-events: none;
	background-color: #4a4a48;
	overflow: hidden;
	// メニュー内容によって書き換える
	ul{
		text-align: center;
		margin-top: 10rem;
		li{
			margin-bottom: 1rem;
			a{
				color: #fff;
			}
		}
	}
	&.js-nav-active {
		pointer-events: initial;
	}
}
              
            
!

JS

              
                // 設定でanimate.jsを読み込んでいる

let _visible;

// ページ読み込み時のイベント
document.addEventListener("DOMContentLoaded", function(event) {
	init();
});

// 初期化部
function init(){
	_visible = false;

	// ハンバーガーメニュー
	document.getElementById( "panel-btn" ).addEventListener( "click", function(e){
		e.preventDefault();
		!_visible ? menuReveal() : menuHide();
	});

}

// トグル処理
function menuToggleState() {

	// メニューアイコン(3本線)
	if ( document.getElementById( "panel-btn" ).classList.contains( "menu-active" ) ){
		document.getElementById( "panel-btn" ).classList.remove( "menu-active" );
	// メニューアイコン(×)
	} else {
		document.getElementById( "panel-btn" ).classList.add( "menu-active" );
	}

	// メニューを閉じる
	if ( document.getElementById( "js-nav-overlay" ).classList.contains( "js-nav-active" ) ){
		document.getElementById( "js-nav-overlay" ).classList.remove( "js-nav-active" );
	// メニューを開く
	} else {
		document.getElementById( "js-nav-overlay" ).classList.add( "js-nav-active" );
	}
}

// メニュー表示アニメーション
function menuReveal() {
	_visible = true;
	menuToggleState();

	// メニュー背景
	anime({
		targets: '.js-menu-animated-background',
		scale: [0.2, 3],
		opacity: [0.2, 1],
		easing: "easeInCubic",
		duration: 300,
	});

	// ナビゲーションコンテンツ
	let containerDelay = 200;
	anime({
		targets: '#js-nav-overlay',
		opacity: [0, 1],
		delay: containerDelay,
		easing: "easeInOutExpo",
		duration: 200
	});
}

// メニュー非表示アニメーション
function menuHide() {
	_visible = false;
	menuToggleState();

	// メニュー背景
	anime({
		targets: '.js-menu-animated-background',
		scale: [4, 0],
		easing: "easeInExpo",
		duration: 400,
	});

	// ナビゲーションコンテンツ
	anime({
		targets: '#js-nav-overlay',
		opacity: [1, 0],
		easing: "easeInOutExpo",
		duration: 200
	});

}
              
            
!
999px

Console