<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Collapsable Menu</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css'><link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- partial:index.partial.html -->
<nav id="side-nav">
<a id="logo" href="#">
<i class="fa fa-codepen"></i></a>
<ul>
<li>
<a href="#">
<i class="fa fa-code"></i>
<span>Pen</span></a>
<ul>
<li><a href="#">New</a></li>
<li><a href="#">Picks</a></li>
<li><a href="#">Popular</a></li>
<li><a href="#">Recent</a></li>
</ul>
</li>
<li class="selected">
<a href="#">
<i class="fa fa-comment-o"></i>
<span>Comment</span></a>
<ul>
<li><a href="#">New</a></li>
<li><a href="#">Popular</a></li>
<li><a href="#">Recent</a></li>
</ul>
</li>
<li>
<a href="#">
<i class="fa fa-heart-o"></i>
<span>Heart</span></a>
</li>
<li>
<a href="#">
<i class="fa fa-paper-plane-o"></i>
<span>Share</span></a>
</li>
<li>
<a href="#">
<i class="fa fa-star-o"></i>
<span>Favorite</span></a>
</li>
</ul>
<a id="toggle">
<i class="fa fa-chevron-circle-left"></i></a>
</nav>
<!-- partial -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script><script src="./script.js"></script>
</body>
</html>
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
*, *:before, *:after {
box-sizing: border-box;
}
html, body {
height: 100%;
width: 100%;
}
body {
color: #444246;
background: -webkit-gradient(linear, left top, left bottom, from(#dd879f), to(#4e337e));
background: linear-gradient(to bottom, #dd879f 0%, #4e337e 100%);
font-family: 'Open Sans', sans-serif;
-webkit-font-smoothing: antialiased;
padding: 10% 0 0 40%;
}
a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
letter-spacing: 0.02em;
}
a:hover {
cursor: pointer;
}
#side-nav {
width: 216px;
background: rgba(255, 255, 255, 0.1);
box-shadow: 0 0 15px 2px rgba(0, 0, 0, 0.1);
-webkit-transition: width 0.5s ease-out;
transition: width 0.5s ease-out;
-webkit-animation: animate-width 1.2s 1 ease-in-out;
animation: animate-width 1.2s 1 ease-in-out;
}
#side-nav.width {
width: 48px;
}
#side-nav.width ul li a span {
opacity: 0;
right: 0;
}
#side-nav.width ul .selected ul {
position: absolute;
right: -8rem;
width: 8rem;
top: 0;
display: none;
left: auto;
-webkit-animation: none;
animation: none;
}
#side-nav.width ul .selected:hover ul {
display: block;
}
#side-nav > ul > li {
display: block;
min-height: 48px;
font-weight: bold;
font-size: 0.76em;
position: relative;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
#side-nav > ul > li:hover, #side-nav > ul > li.selected {
background: rgba(0, 0, 0, 0.1);
}
#side-nav > ul > li:hover > a {
color: #3ed8b5;
-webkit-transition: color 0.2s;
transition: color 0.2s;
}
#side-nav > ul > li:hover ul {
display: block;
}
#side-nav > ul > li.selected ul {
display: block;
left: 0;
position: relative;
width: 100%;
top: 0;
overflow: hidden;
-webkit-animation: animate-height 1.2s 1 ease-in-out;
animation: animate-height 1.2s 1 ease-in-out;
}
#side-nav > ul > li .fa {
font-size: 1.1rem;
padding: 14px;
}
#side-nav > ul > li a {
height: inherit;
display: block;
}
#side-nav > ul > li span {
position: absolute;
right: 0;
height: inherit;
padding: 17px 0 0 0;
left: 48px;
overflow: hidden;
opacity: 1;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
ul li ul {
position: absolute;
right: -8rem;
background: rgba(0, 0, 0, 0.5);
width: 8rem;
top: 0;
display: none;
}
ul li ul li {
display: inline;
}
ul li ul li a {
display: block;
padding: 1em;
}
ul li ul li a:hover {
color: #3ed8b5;
-webkit-transition: color 0.2s;
transition: color 0.2s;
}
#logo {
height: 48px;
background: #333;
display: block;
width: 100%;
position: relative;
}
#logo:before {
background: -webkit-gradient(linear, left top, right top, from(#709AD1), to(#3ed8b5));
background: linear-gradient(to right, #709AD1 0%, #3ed8b5 100%);
height: 2px;
display: block;
content: '';
width: 100%;
bottom: 0;
position: absolute;
}
#logo .fa {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
color: #fff;
font-size: 1.625em;
display: block;
width: 26px;
height: 26px;
}
#toggle {
width: 48px;
height: 48px;
display: block;
padding: 16px;
}
#toggle:hover .fa {
color: #3ed8b5;
}
@-webkit-keyframes animate-width {
0%,40% {
width: 48px;
}
100% {
width: 216px;
}
}
@keyframes animate-width {
0%,40% {
width: 48px;
}
100% {
width: 216px;
}
}
@-webkit-keyframes animate-height {
0%,40% {
height: 0;
}
100% {
height: 100%;
}
}
@keyframes animate-height {
0%,40% {
height: 0;
}
100% {
height: 100%;
}
}
// WIP - Don't hate! I don't know javascript.
$('#toggle').click( function(){
$(this).parent().toggleClass('width');
$(this).children().toggleClass( 'fa-chevron-circle-left').toggleClass( 'fa-chevron-circle-right');
});