<link href="https://fonts.googleapis.com/css?family=Work+Sans:400,600,700&display=swap" rel="stylesheet">
<div class="layout">
<input name="nav" type="radio" class="nav home-radio" id="home" checked="checked" />
<div class="page home-page">
<div class="page-contents">
<h1>Home</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quas voluptates dolore id aspernatur odit minus quidem deleniti ab rerum exercitationem dolores neque officiis explicabo possimus blanditiis sed, voluptatem ut. Ab?</p>
<p><label for="about">Learn more</label></p>
</div>
</div>
<label class="nav" for="home">
<span>
<svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Home
</span>
</label>
<input name="nav" type="radio" class="about-radio" id="about" />
<div class="page about-page">
<div class="page-contents">
<h1>About</h1>
<p>Amet consectetur adipisicing elit. Sed ipsam ad exercitationem, quo quae ullam, quidem laudantium corporis quis minima debitis nesciunt repellat. Quos dolore ex quis voluptas, minus ut?</p>
</div>
</div>
<label class="nav" for="about">
<span>
<svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12" y2="17"></line></svg>
About
</span>
</label>
<input name="nav" type="radio" class="contact-radio" id="contact" />
<div class="page contact-page">
<div class="page-contents">
<h1>Contact</h1>
<p>Eaque accusamus magnam error unde nam, atque provident omnis fugiat quam necessitatibus vel nulla sed quibusdam fuga veritatis assumenda alias quidem asperiores?</p>
<p><a href="#">Get in touch</a></p>
</div>
</div>
<label class="nav" for="contact">
<span>
<svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>
Contact
</span>
</label>
</div>
*{
font-family: 'Work Sans', sans-serif;
}
html, body{
height: 100%;
color: #1a1b1c;
}
label, a{
cursor: pointer;
user-select: none;
text-decoration: none;
display: inline-block;
color: inherit;
transition: border 0.2s;
border-bottom: 5px solid rgba(#8e44ad, 0.2);
padding: 3px 2px;
&:hover{
border-bottom-color: #9b59b6;
}
}
.layout{
display: grid;
height: 100%;
width: 100%;
overflow: hidden;
grid-template-rows: 50px 1fr;
grid-template-columns: 1fr 1fr 1fr;
}
input[type="radio"]{
display: none;
}
label.nav{
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
border-bottom: 2px solid #8e44ad;
background: #ecf0f1;
user-select: none;
transition: background 0.4s, padding-left 0.2s;
padding-left: 0;
input[type="radio"]:checked + .page + &{
background: #9b59b6;
color: #ffffff;
padding-left: 20px;
span{
padding-left: 20px
}
svg{
opacity: 1;
}
}
span{
padding-left: 0px;
position: relative;
}
svg{
left: 0;
top: -3px;
position: absolute;
width: 15px;
opacity: 0;
transition: opacity 0.2s;
}
}
.page{
grid-column-start: 1;
grid-row-start: 2;
grid-column-end: span 3;
padding: 0px 20px;
display: flex;
align-items: center;
}
.page-contents > *{
opacity: 0;
transform: translateY(20px);
transition: opacity 0.2s, transform 0.2s;
@for $c from 1 through 20{
&:nth-child(#{$c}){
transition-delay: 0.2s + ($c * 0.2s);
}
}
}
input[type="radio"] + .page{
transition: transform 0.2s;
transform: translateX(100%);
}
input[type="radio"]:checked + .page{
transform: translateX(0%);
.page-contents > *{
opacity: 1;
transform: translateY(0px);
}
}
.page-contents{
max-width: 100%;
width: 500px;
margin: 0 auto;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.