Skip to content

Instantly share code, notes, and snippets.

@emanualjade
Created June 26, 2013 07:15
Show Gist options
  • Save emanualjade/5865381 to your computer and use it in GitHub Desktop.
Save emanualjade/5865381 to your computer and use it in GitHub Desktop.
A CodePen by Emanual Jade. 3D Nav Cube - Inspired by snowbird.com mobile site. This is meant to be used as a responsive case for smaller mobile devices. This is a quick and dirty test and not ready for use in production.
<div class="page">
<div class="cube-container">
<div class="cube nav-cube">
<div class="search">
<p>Search</p>
<input type="text"/>
</div>
<ul>
<li><a href="">yachts</a></li>
<li><a href="">crew</a></li>
<li><a href="" class="row-end">charters</a></li>
<li><a href="">events</a></li>
<li><a href="">jobs</a></li>
<li><a href="" class="row-end">about</a></li>
<li><a href="">partners</a></li>
<li><a href="">staff</a></li>
<li><a href="" class="row-end">locations</a></li>
</ul>
</div>
</div>
<div class="cube-container">
<div class="cube weather-cube">
<h2>Sunny in Vancouver</h2>
</div>
</div>
<div class="main-content">
<div class="menu">
<div class="border">
<div class="blue"></div>
</div>
<a href="#" class="nav-toggle closed" data-cube="close-switch">
<span>+</span>
</a>
<div class="logo">cardero</div>
<a href="" class="weather-toggle">
<img src="http://s.cdpn.io/49110/clear_night@2x.png" />
</a>
</div>
<div class="hero">
<img src="http://s.cdpn.io/49110/big.jpg" />
</div>
</div>
</div>
$(document).ready(function(){
$('body').on('click', '.nav-toggle.closed', function(e){
var pageDiv = $('.page');
var navCube = $('.nav-cube');
var closeSwitch = $('a[data-cube=close-switch]');
closeSwitch.addClass('opened');
closeSwitch.removeClass('closed');
closeSwitch.data('cube-target', '.nav-cube');
pageDiv.addClass('open');
navCube.addClass('incoming');
e.preventDefault();
});
$('body').on('click', '.nav-toggle.opened', function(){
var pageDiv = $('.page');
var navCubeClass = $(this).data('cube-target');
$(this).removeClass('opened').addClass('closed');
var navCube = $(navCubeClass);
pageDiv.removeClass('open');
navCube.removeClass('incoming');
});
$('.weather-toggle').on('click', function(e){
var pageDiv = $('.page');
var navCube = $('.weather-cube');
var closeSwitch = $('a[data-cube=close-switch]');
closeSwitch.addClass('opened');
closeSwitch.removeClass('closed');
closeSwitch.data('cube-target', '.weather-cube');
pageDiv.addClass('open');
navCube.addClass('incoming');
e.preventDefault();
});
});
body{
margin: 0;
padding: 0;
font-family: helvetica;
background: #000;
}
.cube-container{
-webkit-perspective: 640px;
}
.cube{
position: absolute;
width: 100%;
height: 200px;
background: #fff;
-webkit-transform: translateY(-200px) rotateX(90deg);
-webkit-transform-origin: 50% 200px;
-webkit-transition: -webkit-transform .6s cubic-bezier(0.165,0.840,0.440,1.000);
-webkit-backface-visibility: hidden;
}
.incoming.cube{
display: block;
-webkit-transform: translateY(0px) rotateX(0deg);
-webkit-transform-origin: 50% 200px;
-webkit-transition: -webkit-transform .6s cubic-bezier(0.165,0.840,0.440,1.000);
-webkit-backface-visibility: hidden;
}
.weather-cube{
text-align: center;
background: #fff;
}
.weather-cube h2{
line-height: 200px;
maring: 0;
padding: 0;
}
.nav-cube .search input{
width: 190px;
height: 25px;
border-radius: 7px;
position: relative;
top: -1px;
left: 20px;
border: none;
background: rgb(230, 247, 215);
}
.nav-cube .search{
background: #b6d99f;
height: 50px;
box-sizing: border-box;
padding-left: 15px;
overflow: hidden;
}
.nav-cube .search p{
color: #fff;
font-size: 16px;
line-height: 50px;
margin: 0;
display: inline-block;
font-weight: normal;
}
.nav-cube ul{
margin: 0;
padding: 0;
list-style: none;
}
.nav-cube ul li{
position: relative;
float: left;
width: 33.333%;
height: 50px;
margin: 0;
padding: 0;
}
.nav-cube ul li a{
text-align: center;
line-height: 50px;
display: block;
font-size: 12px;
font-weight: bold;
border-bottom: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;
box-sizing: border-box;
text-transform: uppercase;
text-decoration: none;
}
.nav-cube ul li a.row-end{
border-right: 0;
}
.main-content{
width: 100%;
background: #EBEBEB;
min-height: 900px;
position: absolute;
-webkit-transition: -webkit-transform .6s cubic-bezier(0.165,0.840,0.440,1.000);
-webkit-backface-visibility: hidden;
}
.open .main-content{
-webkit-transform: translateY(200px);
}
.menu{
background: #fff;
height: 50px;
padding: 0;
box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
position: relative;
z-index: 22;
}
.menu .logo{
text-align: center;
line-height: 45px;
}
.menu .border {
background: #b6d99f;
}
.menu .border .blue {
width: 50%;
height: 4px;
background: #7fcde8;
border-right: 1px solid #fff;
}
.menu .nav-toggle{
position: absolute;
display: block;
top: 6px;
width: 40px;
height: 40px;
z-index: 2;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #464646;
}
.menu .nav-toggle span {
display: block;
width: 40px;
height: 40px;
-webkit-transition: -webkit-transform .5s ease-out;
text-align: center;
-webkit-backface-visibility: hidden;
}
.open .menu .nav-toggle span{
-webkit-transform: rotate(45deg);
-webkit-backface-visibility: hidden;
}
.menu .weather-toggle{
position: absolute;
right: 0;
display: block;
top: 6px;
width: 40px;
height: 40px;
z-index: 2;
opacity: 1;
-webkit-transition: opacity .6s;
}
.menu .weather-toggle img{
position: relative;
top: 4px;
with: 32px;
height: 32px;
}
.open .weather-toggle{
opacity: 0;
}
a:visited{
color: #464646;
}
a:active{
color: rgb(80, 138, 192);
}
.hero{
position: relative;
}
.hero img{
width: 100%;
height: auto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment