Skip to content

Instantly share code, notes, and snippets.

Created July 16, 2015 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4c4ecb4abd2eb281c742 to your computer and use it in GitHub Desktop.
Save anonymous/4c4ecb4abd2eb281c742 to your computer and use it in GitHub Desktop.
Material navigation with CSS
nav.navigation
ul.nav
li.nav-item.logo
.nav-item-bg
a href="#"
| Policy
b Genius
li.nav-item data-hover="Insurance Types"
.nav-item-bg
a href="#"
| Insurance Types
li.nav-item data-hover="Insurance Checkup"
.nav-item-bg
a href="#"
| Insurance Checkup
li.nav-item data-hover="About"
.nav-item-bg
a href="#"
| About
section.hero
.overlay
.modal
ul.modal-content
li
.content
| Life
li
.content
| Long-Term Disability
li
.content
| Pet
li
.content
| Renters
ul.modal-content-right
li.title
| Your one stop shop for life insurance
li
| Get a life insurance quote
li
| Get a life insurance quote
li
| Get a life insurance quote
var navItem = $('.nav-item');
var overlay = $('.overlay');
navItem.click(function() {
overlay.addClass('is-active')
});
overlay.click(function(e) {
if ($(event.target).hasClass("overlay")) {
$(this).removeClass('is-active');
} else {
return false;
}
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
* {
box-sizing: border-box;
}
%after {
content: '';
position: absolute;
z-index: -1;
}
body {
margin: 0;
font-family: 'Open Sans', sans-serif;
font-weight: 300;
font-size: 14px;
color: #FFF;
background: #383C55;
overflow: hidden;
}
.navigation {
width: 100%;
}
.nav {
padding: 0;
margin: 0;
list-style: none;
width: 100%;
}
.nav-item {
overflow: hidden;
position: relative;
display: inline-block;
vertical-align: middle;
width: 20%;
padding: 15px 10px;
text-align: center;
&:first-child {
width: 40%;
}
}
.nav-item-bg {
position: absolute;
z-index: -1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #F1682F;
&:after {
position: absolute;
background-color: #F1682F;
content: '';
top: 0;
left: 0;
width: 0%;
height: 100%;
transition: all 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
}
.nav-item a{
color: #FFF;
font-size: 16px;
text-decoration: none;
display: block;
}
.nav-item:hover {
.nav-item-bg:after {
width: 100%;
background-color: #de4c0f;
}
}
.hero {
height: 450px;
background: #385E97;
}
.overlay {
border-radius: 50%;
width: 0px;
height: 0px;
position: absolute;
top: -100%;
left: -50%;
background: rgba(0,0,0,0.5);
opacity: 0;
border-radius: 50%;
transition: all 1200ms cubic-bezier(0.000, 0.995, 0.990, 1.000);
transition-delay: 350ms;
&.is-active {
width: 200%;
height: 300%;
opacity: 1;
transition: all 600ms cubic-bezier(0.000, 0.995, 0.990, 1.000);
.modal {
width: 800px;
height: 450px;
opacity: 1;
border-radius: 0;
transition: all 600ms cubic-bezier(0.23, 1, 0.32, 1);
transition-delay: 600ms;
.modal-content-right {
background: #FFF;
height: 100%;
li {
color: #385e97;
border-bottom: 1px solid #385e97;
opacity: 1;
transform: translateX(0);
transition: all 250ms cubic-bezier(0.000, 0.995, 0.990, 1.000);
&:first-of-type {
border-bottom: 0;
}
}
li:nth-of-type(1){
transition-delay: 2000ms;
}
li:nth-of-type(2){
transition-delay: 2200ms;
}
li:nth-of-type(3) {
transition-delay: 2400ms;
}
li:nth-of-type(4){
transition-delay: 2600ms;
}
li:nth-of-type(5){
transition-delay: 2800ms;
}
}
.modal-content {
li:nth-of-type(1) {
transform: translateX(0);
transition: all 250ms cubic-bezier(0.000, 0.995, 0.990, 1.000);
transition-delay: 1000ms;
background: #FFF;
.content {
color: #385e97;
}
}
li {
transform: translateX(0);
transition: transform 250ms cubic-bezier(0.000, 0.995, 0.990, 1.000);
}
li:nth-of-type(1) {
transition-delay: 1100ms;
}
li:nth-of-type(2) {
transition-delay: 1300ms;
}
li:nth-of-type(3) {
transition-delay: 1500ms;
}
li:nth-of-type(4) {
transition-delay: 1700ms;
}
}
}
}
}
.modal {
position: absolute;
width: 0;
height: 0;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #31558A;
color: #7f8c8d;
opacity: 1;
transition: all 200ms cubic-bezier(0.000, 0.995, 0.990, 1.000);
overflow: hidden;
.modal-content {
margin: 0;
padding: 0;
width: 30%;
float: left;
height: 100%;
overflow: hidden;
li {
list-style: none;
display: block;
height: 25%;
overflow: hidden;
width: 100%;
background: #385E97;
border-bottom: 1px solid #214273;
transform: translateX(-110%);
&:before {
content: "";
display: inline-block;
vertical-align: middle;
height: 100%;
}
}
}
.modal-content-right {
float: left;
width: 70%;
padding: 0;
margin: 0;
list-style: none;
li {
display: block;
padding:10px 5px;
color: #FFF;
font-size: 16px;
margin: 10px 20px;
border-bottom: 1px solid white;
transform: translateY(10px);
opacity: 0;
&.title {
border-bottom: 0;
color: #ededed;
font-size: 18px;
font-weight: bold;
font-style: italic;
margin-bottom: 30px;
}
}
}
h1 {
margin: 0;
}
.content {
display: inline-block;
vertical-align: middle;
padding: 3px 15px;
color: #FFF;
font-size: 16px;
font-weight: bold;
}
}
@media only screen and (max-width: 800px) {
.nav-item {
width: 100%;
}
.nav-item.logo {
width: 100%;
}
.overlay {
top: -25%;
left: -100%;
border-radius: 50%;
}
.overlay.is-active {
width: 300%;
height: 150%;
.modal {
width: 30%;
margin: auto;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment