[パーツ]フルスクリーンメニュー ページ内リンクでフルスクリーンメニューを出してコンテンツを切り替える

CSS HTML
 2018.07.09

ページ内リンクでフルスクリーンメニューを出してコンテンツを切り替える

ページ内リンクでフルスクリーンメニューを出してコンテンツを切り替えるバージョンです。

browser:  65 11 20 11 
ニャン易度 
<a class="hamburger" href="#cp_fullscreenmenu"></a>
<ul id="cp_fullscreenmenu">
<li><a href="#cp_fmcontent-1">1つ目のコンテンツメニュー</a></li>
<li><a href="#cp_fmcontent-2">2つ目のコンテンツメニュー</a></li>
<li><a href="#cp_fmcontent-3">3つ目のコンテンツメニュー</a></li>
<li><a href="#cp_fmcontent-4">4つ目のコンテンツメニュー</a></li>
</ul>
<div class="contents">
<div id="cp_fmcontent-1">
	<h1>1つ目のコンテンツ</h1>
	<p>1つ目のコンテンツ</p>
</div>
<div id="cp_fmcontent-2">
	<h1>2つ目のコンテンツ</h1>
	<p>2つ目のコンテンツ</p>
</div>
<div id="cp_fmcontent-3">
	<h1>3つ目のコンテンツ</h1>
	<p>3つ目のコンテンツ</p>
</div>
<div id="cp_fmcontent-4">
	<h1>4つ目のコンテンツ</h1>
	<p>4つ目のコンテンツ</p>
</div>
</div>
* {
	-webkit-box-sizing: border-box;
	        box-sizing: border-box;
}
a,
a:visited,
a:hover,
a:active {
	text-decoration: none;
	color: inherit;
}
.cp_fullscreenmenu {
	position: fixed;
	z-index: 1;
	top: 0;
	left: 0;
}
.hamburger {
  position: relative;
	margin: 0.5em;
	width: 30px;
	height: 30px;
	display: inline-block;
	border-top: 2px solid #000;
}
.hamburger:hover { color: #999 }
.hamburger:before {
	content: '';
	position: absolute;
	top: 7px;
	left: 0;
	width: 100%;
	height: 7px;
	border-top: 2px solid #000;
	border-bottom: 2px solid #000;
}
/*menuコンテンツ*/
#cp_fullscreenmenu {
	position: fixed;
	top: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	margin-top: 0;
	padding-left: 0;
	list-style-type: none;
	transition: all 0.3s ease;
	transform: scale(0);
	opacity: 0;
	background-color: rgba(41,98,255,0.7);
	z-index: 999;

	align-items: center;
	justify-content: center;
}
#cp_fullscreenmenu:target {
	transform: scale(1);
	opacity: 1;
}
#cp_fullscreenmenu:target > li {
	transition: all 0.5s ease-out;
	transform: translateX(0);
	opacity: 1;
}
#cp_fullscreenmenu > li {
	transition: all 0.3s ease-out;
	transform: translateX(-100%);
	opacity: 0;
	height: 80px;
}
#cp_fullscreenmenu > li:nth-of-type(1) {
	transition-delay: 0.2s;
}
#cp_fullscreenmenu > li:nth-of-type(2) {
	transition-delay: 0.4s;
}
#cp_fullscreenmenu > li:nth-of-type(3) {
	transition-delay: 0.6s;
}
#cp_fullscreenmenu > li:nth-of-type(4) {
	transition-delay: 0.8s;
}
#cp_fullscreenmenu > li > a {
	font-size: 180%;
	color: #ffffff;
	transition: all 0.3s ease-out;
}
#cp_fullscreenmenu > li > a:hover {
	font-size: 230%;
	color: #3949AB;
}
[id^=cp_fmcontent] {
	display: none;
}
[id^=cp_fmcontent]:target {
	display: block;
}

copypet.jp

CSS3などで新たに追加された要素・装飾方法など、日々コードを書いていないと忘れてしまったり、ささっとプロトタイプを作る時などちょっとしたことに時間をかけている暇はない。そんな時に「あ〜、あれストックしときゃよかったなぁ」って困った自分用のストックブログです。カスタマイズなどがしやすいよう、昨今のweb制作に取り入れられる一般的なコードを中心に掲載しています。

More Info

こんな記事はいかがですか?