webサイトデザインAI入門科授業用ブログ

池袋フェリカテクニカルアカデミーの求職者支援訓練webサイトデザインAI入門科10月クラスの授業解説ブログです。

フルスクリーンナビゲーションの作成

PCレイアウト時にもナビゲーションを隠し、ハンバーガーメニューを付け、全画面で表現をする機会が増えてきました。サイトに合わせた構成をいくつか覚えておきましょう。


www.lumine.co.jp




webdesignday.jp





pulpxstyle.com



index.html

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>フルスクリーンナビゲーション</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header>
<h1>Full-screen-nav</h1>
<p id="nav-btn"><span></span></p>
<nav id="g-nav">
<div class="nav-inner">
<ul>
<li><a href="#">Top</a></li>
<li><a href="#about">About</a></li>
<li><a href="#works">Works</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
<div class="nav-box">
<h3>SNS</h3>
<p class="sns-list"><a href="#">Twitter</a></p>
</div>
</div><!-- /.nav-inner -->
</nav>
<div class="main-visual">
<img src="img/main.jpg" alt="">
</div>
</header>


<div class="contents" id="about">
<h2>About</h2>
</div>
<div class="contents" id="works">
<h2>Works</h2>
</div>
<div class="contents" id="contact">
<h2>Contact</h2>
</div>
<footer>

</footer>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(function(){
//#nav-btnをon.clickしたら
$('#nav-btn').on('click',function(){
//thisに.clickをtoggleClassする
$(this).toggleClass('click');
//#g-navをfadeToggleさせる
$('#g-nav').fadeToggle();
});

//#g-nav aをon.clickしたら
$('#g-nav a').on('click',function(){
$('#g-nav').fadeOut();
$('#nav-btn').removeClass('click');
});
});
</script>

</body>
</html>


style.css

@charset "utf-8";
/* ress.css • v1.2.2* MIT License* github.com/filipelinhares/ress*/html{box-sizing:border-box;-webkit-text-size-adjust:100%}*,:after,:before{background-repeat:no-repeat;box-sizing:inherit}:after,:before{text-decoration:inherit;vertical-align:inherit}*{padding:0;margin:0;box-sizing:border-box}audio:not([controls]){display:none;height:0}hr{overflow:visible}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}summary{display:list-item}small{font-size:80%}[hidden],template{display:none}abbr[title]{border-bottom:1px dotted;text-decoration:none}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}code,kbd,pre,samp{font-family:monospace,monospace}b,strong{font-weight:bolder}dfn{font-style:italic}mark{background-color:#ff0;color:#000}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}input{border-radius:0}[role=button],[type=button],[type=reset],[type=submit],button{cursor:pointer}[disabled]{cursor:default}[type=number]{width:auto}[type=search]{-webkit-appearance:textfield}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}textarea{overflow:auto;resize:vertical}button,input,optgroup,select,textarea{font:inherit}optgroup{font-weight:700}button{overflow:visible}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:0;padding:0}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button:-moz-focusring{outline:1px dotted ButtonText}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}button,select{text-transform:none}button,input,select,textarea{background-color:transparent;border-style:none;color:inherit}select{-moz-appearance:none;-webkit-appearance:none}select::-ms-expand{display:none}select::-ms-value{color:currentColor}legend{border:0;color:inherit;display:table;max-width:100%;white-space:normal}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}img{border-style:none;vertical-align: bottom}progress{vertical-align:baseline}svg:not(:root){overflow:hidden}audio,canvas,progress,video{display:inline-block}@media screen{[hidden~=screen]{display:inherit}[hidden~=screen]:not(:active):not(:focus):not(:target){position:absolute!important;clip:rect(0 0 0 0)!important}}[aria-busy=true]{cursor:progress}[aria-controls]{cursor:pointer}[aria-disabled]{cursor:default}::-moz-selection{background-color:#b3d4fc;color:#000;text-shadow:none}::selection{background-color:#b3d4fc;color:#000;text-shadow:none}ul,ol{list-style:none;}a{text-decoration:none;}.wrapper{overflow:hidden;}body{overflow-y:scroll;}img{max-width:100%;}

header{
width: 100%;
height: 100vh;
position: relative;
}
h1{
position: absolute;
}
#nav-btn{
width: 80px;
height: 80px;
background-color: rgba(255,255,255,0.5);
position: fixed;
z-index: 1000;
top: 30px;
right: 30px;
cursor: pointer;
}
#nav-btn>span{
width: 50px;
height: 2px;
background-color: #000;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
transition: 0.1s;
}
#nav-btn>span::before{
display: block;
content: "";
width: 50px;
height: 2px;
background-color: #000;
position: absolute;
top: -30px;
right: 0;
bottom: 0;
left: 0;
margin: auto;
transition: 0.2s;
}
#nav-btn>span::after{
display: block;
content: "";
width: 50px;
height: 2px;
background-color: #000;
position: absolute;
top: 0;
right: 0;
bottom: -30px;
left: 0;
margin: auto;
transition: 0.2s;
}
#nav-btn.click>span{
background-color: transparent;
}
#nav-btn.click>span::before{
top: 0;
transform: rotate(45deg);
}
#nav-btn.click>span::after{
bottom: 0;
transform: rotate(-45deg);
}
#g-nav{
/* display: none; */
width: 100%;
height: 100vh;
background-color: #e3e3dc;
position: fixed;
top: 0;
left: 0;
}
.nav-inner{
width: 60%;
margin: 200px auto 0;
display: flex;
justify-content: center;
background-color: #d17878;
}
.nav-inner ul{
border-right: 2px solid #333;
padding: 0 100px;
}
.nav-inner li{
margin-bottom: 20px;
}
.nav-inner a{
font-size: 26px;
color: #222;
}
.nav-inner a:hover{
text-decoration-line:underline;
text-decoration-color: #d17878;
text-decoration-thickness: 4px;
text-underline-offset: 4px;
}
.nav-box{
padding: 0 100px;
}
.main-visual{
width: 100%;
height: 100vh;
}
.main-visual>img{
object-fit: cover;
width: 100%;
height: 100%;
}
.contents{
height: 120vh;
padding-top: 50px;
}
h2{
text-align: center;
font-size: 30px;
}
footer{
height: 100px;
background-color: cadetblue;
}