A Pen by Jesse Showalter on CodePen.
Created
June 12, 2016 01:40
-
-
Save jesseshowalter/6e44857faa3a2f8d333b1722038ef887 to your computer and use it in GitHub Desktop.
Multi Level Trunk.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<header class="slide"> | |
<!-- Add "slideRight" class to items that move right when viewing Nav Drawer --> | |
<ul id="navToggle" class="burger slide"> | |
<!-- Add "slideRight" class to items that move right when viewing Nav Drawer --> | |
<li></li> | |
<li></li> | |
<li></li> | |
</ul> | |
<h1>Navigation</h1> | |
</header> | |
<nav class="slide"> | |
<ul> | |
<li><a href="#" class="active">HOME</a></li> | |
<li><a href="#">LINK TWO</a></li> | |
<li> | |
<a href="#">LINK THREE</a> | |
<ul> | |
<li><a href="#">DROPDOWN ONE</a></li> | |
<li><a href="#">DROPDOWN TWO</a></li> | |
<li><a href="#">DROPDOWN THREE</a></li> | |
</ul> | |
</li> | |
<li> | |
<a href="#">LINK FOUR</a> | |
<ul> | |
<li><a href="#">DROPDOWN ONE</a></li> | |
<li><a href="#">DROPDOWN TWO</a></li> | |
<li><a href="#">DROPDOWN THREE</a></li> | |
</ul> | |
</li> | |
</ul> | |
</nav> | |
<div class="content slide"> | |
<!-- Add "slideRight" class to items that move right when viewing Nav Drawer --> | |
<ul class="responsive"> | |
<li class="header-section"> | |
<p class="placefiller">HEADER</p> | |
</li> | |
<li class="body-section"> | |
<p class="placefiller">BODY</p> | |
</li> | |
</ul> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
function mobilecheck() { | |
var check = false; | |
(function(a) { | |
if (/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) { | |
check = true; | |
} | |
})(navigator.userAgent || navigator.vendor || window.opera); | |
return check; | |
} | |
var clickevent = mobilecheck() ? 'touchstart' : 'click'; | |
var items = $('.slide'); | |
var content = $('.content'); | |
function open() { | |
$(items).removeClass('close').addClass('open'); | |
} | |
function close() { | |
$(items).removeClass('open').addClass('close'); | |
} | |
$('#navToggle').on(clickevent, function(event) { | |
event.stopPropagation(); | |
event.preventDefault(); | |
if (content.hasClass('open')) { | |
close(); | |
} else { | |
open(); | |
} | |
}); | |
content.click(function() { | |
if (content.hasClass('open')) { | |
close(); | |
} | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: #000; | |
font: 12px "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; | |
color: #9aa6af; | |
text-rendering: optimizelegibility; | |
-webkit-tap-highlight-color:rgba(0,0,0,0); | |
-webkit-text-size-adjust: none; | |
-webkit-font-smoothing: antialiased; | |
-moz-tap-highlight-color:rgba(0,0,0,0); | |
-moz-text-size-adjust: none; | |
-moz-font-smoothing: antialiased; | |
-ms-tap-highlight-color:rgba(0,0,0,0); | |
-ms-text-size-adjust: none; | |
-ms-font-smoothing: antialiased; | |
} | |
a {text-decoration: none;} | |
.container { | |
//overflow: hidden; | |
background-color: #000; | |
/* Prevents Flickering */ | |
-webkit-backface-visibility: hidden; | |
-moz-backface-visibility: hidden; | |
-ms-backface-visibility: hidden; | |
} | |
header { | |
height: 60px; | |
//position: relative; | |
background-color: #f3f5f6; | |
} | |
header h1 { | |
color: #9aa6af; | |
text-align: left; | |
font-size: 27px; | |
line-height: 60px; | |
font-weight: bold; | |
padding-left: 20px; | |
} | |
.burger { | |
position: absolute; | |
float: left; | |
padding: 10px; | |
top: 4px; | |
left: 10px; | |
display: none; | |
} | |
.burger li { | |
width: 30px; | |
height: 4px; | |
background-color: #fff; | |
border-radius: 3px; | |
margin: 5px 0; | |
} | |
ul.burger:hover{ | |
cursor: pointer; | |
} | |
.burger.open li {background-color: #d9dde1;} | |
nav { | |
position: absolute; | |
top: 0; | |
right: 5px; | |
} | |
nav li { | |
float: left; | |
display: inline-block; | |
} | |
nav li a { | |
font-size: 11px; | |
color: #9aa6af; | |
padding: 24px 10px; | |
display: block; | |
} | |
nav li a:hover {color: #000;} | |
// The dropdown | |
nav li ul{ | |
position: absolute; | |
border-left:1px solid #CCC; | |
border-right:1px solid #CCC; | |
border-bottom:1px solid #CCC; | |
display:none; | |
width: 200px; | |
text-align: left; | |
opacity: 0.85; | |
margin-left: -118px; | |
} | |
nav li ul li{ | |
background:white; | |
display:inline; | |
float:left; | |
width:100%; | |
&:hover{ | |
background:#a5e9f5; | |
color: white; | |
} | |
a{ | |
padding: 16px 20px; | |
color: #67b1c5; | |
} | |
} | |
nav li:hover ul{ | |
display:inline-block; | |
} | |
//----------------------------- | |
//----- Responsive Navigation | |
//----------------------------- | |
@media only screen and (max-width: 580px) { | |
header { | |
height: 60px; | |
z-index: 2; | |
background-color: #060a0c; | |
position: fixed; | |
top: 0; | |
right: 0; | |
left: 0; | |
/* starting point */ | |
-webkit-transform: translate3d(0,0,0); | |
-moz-transform: translate3d(0,0,0); | |
transform: translate3d(0,0,0); | |
} | |
header h1 { | |
color: #ffffff; | |
text-align: center; | |
padding-left: 0; | |
display: block; | |
} | |
.burger {display: block;} | |
/* Nav Drawer Layout */ | |
nav {position: relative;} | |
nav ul { | |
height: 100%; | |
overflow-y: auto; | |
} | |
nav li { | |
display: block; | |
float: none; | |
} | |
nav li a { | |
padding: 22px 25px; | |
letter-spacing: 3px; | |
font-size: 14px; | |
} | |
nav li a.logo { | |
display: none; | |
} | |
nav li a.active { | |
color: #fff; | |
background-color: #141e23; | |
} | |
nav li a:hover { | |
color: #fff; | |
background-color: #19252c; | |
} | |
// nav li:first-child a.active, | |
// nav li:first-child a:hover | |
// {border-radius: 10px 0 0 0;} | |
.header-section {margin-top: 60px;} | |
nav li:hover ul{ | |
display:block; | |
} | |
nav li ul{ | |
position: relative; | |
border:none; | |
display: block; | |
width: 100%; | |
text-align: left; | |
opacity: 1; | |
margin:0; | |
} | |
nav ul li ul li{ | |
height: auto; | |
background:#141e23; | |
display:block; | |
padding:0; | |
a{ | |
font-size:1em; | |
margin-left:6px; | |
} | |
a:before{ | |
content:"- "; | |
} | |
a:hover{ | |
color: #fff; | |
background-color: #19252c; | |
} | |
} | |
/* NAVIGATION ANNIMATION */ | |
nav { | |
width: 93%; | |
height: 100%; | |
position: fixed; | |
left: 0; | |
top: 0; | |
margin: 0; | |
background-color: #1d2d35; | |
border-radius: 8px; | |
/* starting point */ | |
opacity: .3; | |
-webkit-transform: translate3d(5%,0,0)scale(.97); | |
-moz-transform: translate3d(5%,0,0)scale(.97); | |
transform: translate3d(5%,0,0)scale(.97); | |
} | |
/*Nav Expanding Open Effect*/ | |
nav.open { | |
opacity: 1; | |
-webkit-transform: translate3d(0,0,0)scale(1); | |
-webkit-animation: slideIn .35s ease-in-out; | |
-moz-transform: translate3d(0,0,0)scale(1); | |
-moz-animation: slideIn .35s ease-in-out; | |
transform: translate3d(0,0,0)scale(1); | |
animation: slideIn .35s ease-in-out; | |
} | |
@-webkit-keyframes slideIn { | |
0% {opacity: .3; | |
-webkit-transform: translate3d(5%,0,0)scale(.97);} | |
100% {opacity: 1; | |
-webkit-transform: translate3d(0,0,0)scale(1);} | |
} | |
@-moz-keyframes slideIn { | |
0% {opacity: .3; | |
-moz-transform: translate3d(5%,0,0)scale(.97);} | |
100% {opacity: 1; | |
-moz-transform: translate3d(0,0,0)scale(1);} | |
} | |
@keyframes slideIn { | |
0% {opacity: .3; | |
transform: translate3d(5%,0,0)scale(.97);} | |
100% {opacity: 1; | |
transform: translate3d(0,0,0)scale(1);} | |
} | |
/*Nav Shrinking Closed Effect*/ | |
nav.close { | |
opacity: .3; | |
-webkit-transform: translate3d(5%,0,0)scale(.97); | |
-webkit-animation: slideOut .3s ease-in-out; | |
-moz-transform: translate3d(5%,0,0)scale(.97); | |
-moz-animation: slideOut .3s ease-in-out; | |
transform: translate3d(5%,0,0)scale(.97); | |
animation: slideOut .3s ease-in-out; | |
} | |
@-webkit-keyframes slideOut { | |
0% {opacity: 1; | |
-webkit-transform: translate3d(0,0,0)scale(1);} | |
100% {opacity: .3; | |
-webkit-transform: translate3d(5%,0,0)scale(.97);} | |
} | |
@-moz-keyframes slideOut { | |
0% {opacity: 1; | |
-moz-transform: translate3d(0,0,0)scale(1);} | |
100% {opacity: .3; | |
-moz-transform: translate3d(5%,0,0)scale(.97);} | |
} | |
@keyframes slideOut { | |
0% {opacity: 1; | |
transform: translate3d(0,0,0)scale(1);} | |
100% {opacity: .3; | |
transform: translate3d(5%,0,0)scale(.97);} | |
} | |
/* CONTENT ANNIMATION */ | |
.content { | |
/* starting point */ | |
-webkit-transform: translate3d(0,0,0); | |
-moz-transform: translate3d(0,0,0); | |
transform: translate3d(0,0,0); | |
z-index: 1; | |
} | |
/*Content Sliding Open Effect*/ | |
header.open, | |
.content.open | |
{ | |
-webkit-transform: translate3d(240px,0,0); | |
-webkit-animation: open .5s ease-in-out; | |
-moz-transform: translate3d(240px,0,0); | |
-moz-animation: open .5s ease-in-out; | |
transform: translate3d(240px,0,0); | |
animation: open .5s ease-in-out; | |
} | |
@-webkit-keyframes open { | |
0% {-webkit-transform: translate3d(0,0,0);} | |
70% {-webkit-transform: translate3d(260px,0,0);} | |
100% {-webkit-transform: translate3d(240px,0,0);} | |
} | |
@-moz-keyframes open { | |
0% {-moz-transform: translate3d(0,0,0);} | |
70% {-moz-transform: translate3d(260px,0,0);} | |
100% {-moz-transform: translate3d(240px,0,0);} | |
} | |
@keyframes open { | |
0% {transform: translate3d(0,0,0);} | |
70% {transform: translate3d(260px,0,0);} | |
100% {transform: translate3d(240px,0,0);} | |
} | |
/*Content Sliding Closed Effect*/ | |
header.close, | |
.content.close | |
{ | |
-webkit-transform: translate3d(0,0,0); | |
-webkit-animation: close .3s ease-in-out; | |
-moz-transform: translate3d(0,0,0); | |
-moz-animation: close .3s ease-in-out; | |
transform: translate3d(0,0,0); | |
animation: close .3s ease-in-out; | |
} | |
@-webkit-keyframes close { | |
0% {-webkit-transform: translate3d(240px,0,0);} | |
100% {-webkit-transform: translate3d(0,0,0);} | |
} | |
@-moz-keyframes close { | |
0% {-moz-transform: translate3d(240px,0,0);} | |
100% {-moz-transform: translate3d(0,0,0);} | |
} | |
@keyframes close { | |
0% {transform: translate3d(240px,0,0);} | |
100% {transform: translate3d(0,0,0);} | |
} | |
} | |
/* Removable CSS */ | |
.header-section, | |
.body-section, | |
.footer-section | |
{padding: 20px;} | |
.header-section {background-color: #ffffff;} | |
.body-section {background-color: #f4f5f6;} | |
.placefiller { | |
text-align: center; | |
font-size: 20px; | |
} | |
.header-section .placefiller {line-height: 300px;} | |
.body-section .placefiller {line-height: 600px;} | |
.footer-section .placefiller { | |
line-height: 200px; | |
border: 1px dashed rgba(190, 196, 202, 0.9); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment