コピペでできる!cssとhtmlのみで作るフルスクリーンメニュー4選

CSS HTML
Update 2018.07.09

全画面を覆うようなフルスクリーンのメニューはメニュー数が少ない時や、ランディングページなどにも使い勝手が良いと思います。
そんなフルスクリーンメニューを4つご紹介。

browser:  65 11 20 11(一部非対応) 

フルスクリーンメニュー[4選]

左のメニューをクリックすると出てくるフルスクリーンメニュー

ニャン易度
<div class="contents">
<h1>Contents</h1>
<p>コンテンツ</p>
</div>
<div class="cp_fullscreenmenu">
<input class="toggle" type="checkbox" />
<div class="hamburger"><span></span></div>
<div class="menu">
<div>
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</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;
}
/*menuコンテンツ*/
.cp_fullscreenmenu .menu {
position: fixed;
top: 0;
left: 0;
display: flex;
visibility: hidden;
overflow: hidden;
width: 100%;
height: 100%;
pointer-events: none;
outline: 1px solid transparent;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
align-items: center;
justify-content: center;
}
.cp_fullscreenmenu .menu > div {
display: flex;
overflow: hidden;
width: 200vw;
height: 200vw;
transition: all 0.4s ease;
-webkit-transform: scale(0);
transform: scale(0);
text-align: center;
color: #fefefe;
border-radius: 50%;
background: rgba(0,131,143 ,0.8);
flex: none;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
align-items: center;
justify-content: center;
}
.cp_fullscreenmenu .menu > div > ul {
display: block;
max-height: 100vh;
margin: 0;
padding: 0 1em;
list-style: none;
transition: opacity 0.4s ease;
opacity: 0;
}
.cp_fullscreenmenu .menu > div > ul > li {
font-size: 24px;
display: block;
margin: 1em;
padding: 0;
}
.cp_fullscreenmenu .menu > div > ul > li > a {
position: relative;
display: inline;
cursor: pointer;
transition: color 0.4s ease;
}
.cp_fullscreenmenu .menu > div > ul > li > a:hover {
color: #e5e5e5;
}
.cp_fullscreenmenu .menu > div > ul > li > a:hover:after {
width: 100%;
}
.cp_fullscreenmenu .menu > div > ul > li > a:after {
position: absolute;
z-index: 1;
bottom: -0.15em;
left: 0;
width: 0;
height: 2px;
content: '';
transition: width 0.4s ease;
background: #e5e5e5;
}
/*クリックしたらメニューが開閉の動作*/
.cp_fullscreenmenu .toggle {
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: 60px;
height: 60px;
cursor: pointer;
opacity: 0;
}
.cp_fullscreenmenu .toggle:checked + .hamburger > span {
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
.cp_fullscreenmenu .toggle:checked + .hamburger > span:before,
.cp_fullscreenmenu .toggle:checked + .hamburger > span:after {
top: 0;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.cp_fullscreenmenu .toggle:checked + .hamburger > span:after {
opacity: 0;
}
.cp_fullscreenmenu .toggle:checked ~ .menu {
visibility: visible;
pointer-events: auto;
}
.cp_fullscreenmenu .toggle:checked ~ .menu > div {
transition-duration: 0.75s;
-webkit-transform: scale(1);
transform: scale(1);
}
.cp_fullscreenmenu .toggle:checked ~ .menu > div > ul {
opacity: 1;
}
.cp_fullscreenmenu .toggle:checked ~ .menu > div > ul li:nth-of-type(1) {
transition-delay: 0.4s;
}
.cp_fullscreenmenu .toggle:checked ~ .menu > div > ul li:nth-of-type(2) {
transition-delay: 0.6s;
}
.cp_fullscreenmenu .toggle:checked ~ .menu > div > ul li:nth-of-type(3) {
transition-delay: 0.8s;
}
.cp_fullscreenmenu .toggle:checked ~ .menu > div > ul li:nth-of-type(4) {
transition-delay: 1.0s;
}
.cp_fullscreenmenu .toggle:hover + .hamburger {
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}
.cp_fullscreenmenu .toggle:checked:hover + .hamburger > span {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
/*ハンバーガー*/
.cp_fullscreenmenu .hamburger {
position: absolute;
z-index: 1;
top: 0;
left: 0;
display: block;
width: 60px;
height: 60px;
padding: 0.5em 1em;
cursor: pointer;
transition: box-shadow 0.4s ease;
border-radius: 0 0.12em 0.12em 0;
background: rgba(0,151,167 ,0.7);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.cp_fullscreenmenu .hamburger > span {
position: relative;
top: 50%;
display: block;
width: 100%;
height: 2px;
transition: all 0.4s ease;
background: #fefefe;
}
.cp_fullscreenmenu .hamburger > span:before,
.cp_fullscreenmenu .hamburger > span:after {
position: absolute;
z-index: 1;
top: -10px;
left: 0;
display: block;
width: 100%;
height: 2px;
content: '';
transition: all 0.4s ease;
background: inherit;
}
.cp_fullscreenmenu .hamburger > span:after {
top: 10px;
}

右のメニューをクリックしたら出てくるグラデーション背景のフルスクリーンメニュー

ニャン易度
<div class="contents">
<h1>Contents</h1>
<p>コンテンツ</p>
</div>
<div class="cp_fullscreenmenu">
<input type="checkbox" id="menuToggle" />
<label for="menuToggle" class="hamburger">
<div class="open"></div>
</label>
<div class="menu menuEffects">
<label for="menuToggle"></label>
<div class="menucont">
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</div>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
a,
a:visited,
a:hover,
a:active {
text-decoration: none;
color: inherit;
}
input {
display: none;
}
.cp_fullscreenmenu {
position: fixed;
z-index: 1;
top: 0;
right: 0;
}
/*menuコンテンツ*/
.cp_fullscreenmenu .menu {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-image: linear-gradient(to top, rgba(255,8,68,0.8) 0%, rgba(255,177,153,0.7) 100%);
}
.cp_fullscreenmenu .menu label {
position: absolute;
top: 20px;
right: 20px;
width: 30px;
height: 30px;
cursor: pointer;
background-size: 100%;
}
.cp_fullscreenmenu .menu .menucont {
font-size: 54px;
position: relative;
top: 50%;
margin-top: -170px;
padding-bottom: 20px;
text-align: center;
}
.cp_fullscreenmenu .menu ul {
margin: 0 auto;
padding: 0;
list-style: none;
}
.cp_fullscreenmenu .menu ul li,
.cp_fullscreenmenu .menu ul li a {
transition: all 0.3s ease;
}
.cp_fullscreenmenu .menu ul li a {
display: block;
padding: 10px 0;
color: #ffffff;
}
.cp_fullscreenmenu .menu ul li a:hover {
color: #ff0844;
}
.cp_fullscreenmenu .menu ul li:hover {
background: #ffffff;
}
/*クリックしたらメニューが開閉の動作*/
.cp_fullscreenmenu .menuEffects {
visibility: hidden;
transition: opacity 0.5s, visibility 0.5s;
opacity: 0;
}
.cp_fullscreenmenu .menuEffects ul {
transition: all 0.5s;
transform: translateY(0%);
}
.cp_fullscreenmenu #menuToggle:checked ~ .menuEffects {
visibility: visible;
transition: opacity 0.5s;
opacity: 1;
}
.cp_fullscreenmenu #menuToggle:checked ~ .menuEffects ul {
opacity: 1;
}
.cp_fullscreenmenu #menuToggle:checked ~ .hamburger .open {
background-color: transparent;
}
.cp_fullscreenmenu #menuToggle:checked ~ .hamburger .open:before {
position: absolute;
z-index: 1;
top: 0;
right: 0;
content: '';
transform: rotate(45deg);
background-color: #ffffff;
}
.cp_fullscreenmenu #menuToggle:checked ~ .hamburger .open:after {
position: relative;
z-index: 1;
top: 0;
right: 0;
content: '';
transform: rotate(-45deg);
background-color: #ffffff;
}
.cp_fullscreenmenu #menuToggle:not(:checked) ~ .menuEffects ul {
transform: translateY(-30%);
}
/*ハンバーガー*/
.cp_fullscreenmenu .hamburger {
position: relative;
top: 0;
right: 0;
display: block;
width: 50px;
height: 50px;
padding: 15px;
cursor: pointer;
}
.cp_fullscreenmenu .hamburger:hover .open:before {
top: -9px;
}
.cp_fullscreenmenu .hamburger:hover .open:after {
top: 5px;
}
.cp_fullscreenmenu .open,
.cp_fullscreenmenu .open:before,
.cp_fullscreenmenu .open:after {
position: relative;
display: block;
width: 24px;
height: 4px;
border-radius: 2px;
background-color: #ff0844;
transition: all 0.3s ease;
}
.cp_fullscreenmenu .open {
top: 8px;
cursor: pointer;
}
.cp_fullscreenmenu .open:before {
top: -8px;
content: '';
transform: rotate(0deg);
}
.cp_fullscreenmenu .open:after {
top: 4px;
content: '';
}

右のメニューをクリックしたら出てくるグラデーション背景のフルスクリーンメニュー(テキスト下からぴょこんと表示)

ニャン易度
<div class="contents">
<h1>Contents</h1>
<p>コンテンツ</p>
</div>
<div class="cp_fullscreenmenu">
<input type="checkbox" id="toggle" />
<label class="hamburger" for="toggle">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</label>
<div class="menu">
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
a,
a:visited,
a:hover,
a:active {
text-decoration: none;
color: inherit;
}
input {
display: none;
}
/*menuコンテンツ*/
.cp_fullscreenmenu .menu {
position: fixed;
top: 0;
left: 0;
visibility: hidden;
width: 100%;
height: 100%;
transition: all 0.3s ease-in-out;
opacity: 0;
background-image: linear-gradient(to top, rgba(68,129,235,0.7) 0%, rgba(4,190,254,0.7) 100%);
}
.cp_fullscreenmenu .menu ul {
position: absolute;
top: 170px;
left: 50%;
margin: 0;
padding: 0;
list-style-type: none;
transition: all 0.3s ease-in-out;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
.cp_fullscreenmenu .menu ul li {
-webkit-transform: translateY(50px);
transform: translateY(50px);
opacity: 0;
}
.cp_fullscreenmenu .menu ul li a {
font-size: 2em;
font-weight: bold;
display: block;
padding: 10px 0;
transition: all 0.2s ease-in-out;
text-align: center;
text-decoration: none;
color: #ffffff;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
.cp_fullscreenmenu .menu ul li a:hover {
color: rgba(236,64,122 ,1);
}
/*クリックしたらメニューが開閉の動作*/
.cp_fullscreenmenu #toggle:checked ~ .menu {
visibility: visible;
opacity: 1;
}
.cp_fullscreenmenu #toggle:checked ~ .menu ul {
top: 70px;
}
.cp_fullscreenmenu #toggle:checked ~ .menu ul li {
-webkit-transform: translateY(0px);
transform: translateY(0px);
opacity: 1;
}
.cp_fullscreenmenu #toggle:checked ~ .menu ul li:nth-child(1) {
transition: all 0.3s cubic-bezier(0.6, 0, 0.8, 1.5) 0.1s;
}
.cp_fullscreenmenu #toggle:checked ~ .menu ul li:nth-child(2) {
transition: all 0.3s cubic-bezier(0.6, 0, 0.8, 1.5) 0.2s;
}
.cp_fullscreenmenu #toggle:checked ~ .menu ul li:nth-child(3) {
transition: all 0.3s cubic-bezier(0.6, 0, 0.8, 1.5) 0.3s;
}
.cp_fullscreenmenu #toggle:checked ~ .menu ul li:nth-child(4) {
transition: all 0.3s cubic-bezier(0.6, 0, 0.8, 1.5) 0.4s;
}
.cp_fullscreenmenu #toggle:checked + label.hamburger .bar {
background-color: rgba(255,255,255 ,1);
}
.cp_fullscreenmenu #toggle:checked + label.hamburger .bar:nth-child(2) {
-webkit-transform: translateX(50px);
transform: translateX(50px);
opacity: 0;
}
.cp_fullscreenmenu #toggle:checked + label.hamburger .bar:nth-child(1) {
-webkit-transform: translateY(10px) rotate(45deg);
transform: translateY(10px) rotate(45deg);
}
.cp_fullscreenmenu #toggle:checked + label.hamburger .bar:nth-child(3) {
-webkit-transform: translateY(-8px) rotate(-45deg);
transform: translateY(-8px) rotate(-45deg);
}
/*ハンバーガー*/
.cp_fullscreenmenu .hamburger {
position: fixed;
z-index: 10;
top: 10px;
right: 10px;
display: block;
cursor: pointer;
}
.cp_fullscreenmenu .hamburger .bar {
width: 30px;
height: 2px;
margin: 7px auto;
transition: all 0.3s ease-in-out;
background-color: rgba(240,98,146 ,1);
}
.cp_fullscreenmenu .hamburger .bar:nth-child(2) {
width: 20px;
}

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

ニャン易度
<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

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