<input type="checkbox" id="on">
<main>
<section id="html">HTML</section>
<section id="css">CSS</section>
<section id="js">JS</section>
</main>
<label for="on" class="checkbox"></label>
<nav>
<a href="#html">HTML</a>
<a href="#css">CSS</a>
<a href="#js">JS</a>
</nav>
body {
font-family: 'Helvetica Neue',Helvetica,sans-serif;
margin: 0;
color: #fff;
}
nav {
position: absolute;
top: 0;
left: 50%;
display: flex;
justify-content: space-around;
width: 400px;
margin-left: -200px;
box-sizing: border-box;
padding: 15px;
border-radius: 0 0 4px 4px;
background-color: #000;
font-size: 20px;
line-height: 1;
text-align: center;
}
main {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow-y: scroll;
}
#on:checked ~ main {
scroll-behavior: smooth;
}
section {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
font-size: 100px;
}
.checkbox {
position: absolute;
top: 50px;
left: 50px;
width: 50px;
height: 50px;
background-color: #fff;
border-radius: 4px;
text-align: center;
cursor: pointer;
}
#on:checked ~ .checkbox::after {
content: '✔';
font-size: 50px;
line-height: 1;
color: #00ae8b;
}
#html {
background-color: #f3671c;
}
#css {
background-color: #0071ba;
}
#js {
background-color: #e7a307;
}
#on {
position: absolute;
opacity: 0;
}
a {
display: block;
width: 100px;
text-decoration: none;
color: inherit;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.