JSFiddle - React, Tailwind, and code Playground
by Akshay U
HTML
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<a href="#sidebar" class="btn open">≡</a>
<div class="sidebar" id="sidebar">
<ul>
<li class="center user">
<img src="https://placeimg.com/300/300/people" alt="User" />
<p>John Doe</p>
</li>
<li class="divider"></li>
<li class="title">Links</li>
<li class="item active"><a href="#">Home</a></li>
<li class="item"><a href="#">About</a></li>
<li class="item"><a href="#">Portfolio</a></li>
<li class="item"><a href="#">Testimonials</a></li>
<li class="item"><a href="#">Contact</a></li>
<li class="divider"></li>
<li class="title">Projects</li>
<li class="item"><a href="#">Project 1</a></li>
<li class="item"><a href="#">Project 2</a></li>
<li class="item"><a href="#">Project 3</a></li>
</ul>
</div>
<a href="#!" class="close sidebar-overlay"></a>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #f1f1ff;
font-family: 'Nunito', sans-serif;
}
.btn {
display: inline-block;
height: 40px;
width: 40px;
line-height: 40px;
text-align: center;
background: #fff;
color: #333;
border-radius: 50%;
text-decoration: none;
font-size: 1.2em;
box-shadow: 0 2px 10px -2px rgba(0, 0, 0, .1);
margin: 20px;
}
.sidebar {
width: 80%;
max-width: 300px;
height: 100%;
position: fixed;
left: 0;
top: 0;
background: linear-gradient(to right, #673AB7, #5E35B1);
left: -300px;
transition: left .35s;
}
.sidebar-overlay{
position:fixed;
width:100%;
height:100%;
background: rgba(0,0,0,0.3);
left:100%;
top:0;
z-index: -1;
cursor: default;
}
.sidebar:target{
left: 0;
}
.sidebar:target + .sidebar-overlay{
left:0;
}
ul{
list-style: none;
height: 100%;
overflow:auto;
}
.center{
text-align:center;
}
.user{
padding: 20px;
position: relative;
}
.user img{
width: 150px;
border-radius:50%;
}
.user p{
color: #eee;
padding: 10px 0;
}
.divider{
padding: 0;
height: 1px;
background: #7e57c2;
}
.title{
color: #b39ddb;
text-transform: uppercase;
font-size: 0.8em;
letter-spacing: 1px;
padding: 20px;
padding-bottom: 10px;
}
.item{
background: transparent;
transition: background .35s;
}
.item a{
text-decoration: none;
color: #eee;
display: inline-block;
padding: 20px;
padding-left: 30px;
width: 100%;
}
.item.active,.item:hover{
background: rgba(0,0,0,.1);
}