<header>
<nav>
<ul class="header-inner">
<li><a href="#section1">section1</a></li>
<li><a href="#section2">section2</a></li>
<li><a href="#section3">section3</a></li>
<li><a href="#section4">section4</a></li>
<li><a href="#section5">section5</a></li>
</ul>
</nav>
</header>
<main>
<h2 id="section1" class="section">section1</h2>
<h2 id="section2" class="section">section2</h2>
<h2 id="section3" class="section">section3</h2>
<h2 id="section4" class="section">section4</h2>
<h2 id="section5" class="section">section5</h2>
<p class="back-btn"><a href="#">Topに戻る</a></p>
</main>
* {
box-sizing: border-box;
list-style: none;
margin: 0;
padding: 0;
text-decoration: none;
}
/* ゆっくりに遷移する */
html {
scroll-behavior: smooth;
}
.header-inner {
align-items: center;
background-color: #111934;
display: flex;
height: 80px;
justify-content: space-around;
position: fixed;
top: 0;
width: 100%;
}
.header-inner li {
line-height: 80px;
text-align: center;
transition: .5s;
width: 100%;
}
.header-inner li:hover {
background-color: #717171;
color: #111934;
}
.header-inner li:not(:nth-of-type(5)) {
border-right: 1px solid #fff;
}
.header-inner li a {
color: #e8e8e8;
display: block;
}
@media screen and (max-width: 480px) {
.header-inner li a {
font-size: 12px;
}
}
.section {
background-color: #b5b5b5;
display: flex;
font-size: 40px;
height: 120vh;
justify-content: center;
width: 100%;
scroll-margin-top: 80px;
}
.section:nth-of-type(1) {
padding-top: 80px;
}
.section:nth-of-type(even) {
background-color: #302f2f;
color: #e8e8e8;
}
.back-btn {
background-color: #111934;
border-radius: 16px;
bottom: 20px;
height: 50px;
line-height: 50px;
position: fixed;
right: 20px;
text-align: center;
transform: translateX(-50%);
width: 120px;
}
.back-btn a {
border-radius: 16px;
color: #e8e8e8;
cursor: pointer;
display: block;
height: 100%;
transition: .3s;
width: 100%;
}
.back-btn a:hover {
background-color: #717171;
color: #111934;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.