cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              .phone
  .phone__screen

    .header
      .menu-button
        .menu-button__sub-container.is-menu-btn
          .menu-button__close-state X
          .menu-button__menu-state Menu
          
    .sub-nav
          
    .menu.is-collapsed
      .menu__item Lorem ipsum dolor
      .menu__item Cras nisl mi
      .menu__item Maecenas congue faucibus
      .menu__item Aliquam odio
      
    .content
      .content__hero
      .content__row
        .content__block
      .content__row
        .content__block
        .content__block
      .content__row
        .content__block
      
            
          
!
            
              //=== IMPORTS ===//
@import 'https://fonts.googleapis.com/css?family=Nunito';

//=== VARIABLES ===//
$color__base:           #3498DB;
$color__base--dark:     scale-color($color__base, $lightness: -20%);
$color__gray:           #E8E8E8;
$color__gray--dark:     darken($color__gray, 5%);
$color__accent:         #E14D4C;

$spacing--sm:           .5em;
$spacing--md:           1em;
$spacing--lg:           2em;

$border-radius--md:     .5em;

//=== KEYFRAMES ===//
@keyframes slideUp {
  0% {
    transform: transLateY(0);
  }
  70% {
    transform: translateY(-105%);
  }
  100% {
    transform: translateY(-100%);
  }
}

@keyframes slideUpHalf {
  0% {
    transform: translateY(0);
  }
  70% {
    transform: translateY(-55%);
  }
  100% {
    transform: translateY(-50%);
  }
}

@keyframes slideDown {
  0% {
    transform: translateY(-100%);
  }
  70% {
    transform: translateY(5%);
  }
  100% {
    transform: translateY(0%);
  }
}

@keyframes slideDownHalf {
  0% {
    transform: translateY(-50%);
  }
  70% {
    transform: translateY(5%);
  }
  100% {
    transform: translateY(0);
  }
}

body {
  padding: $spacing--md*2;
  display: flex;
  justify-content: center;
  background: $color__accent;
}

//= Phone component =//
.phone {
  background: darken($color__gray, 70%);
  width: 24em;
  height: 35em;
  padding: $spacing--md*3 $spacing--lg;
  border-radius: $border-radius--md;
  box-shadow: 0 $spacing--md $spacing--lg darken($color__accent, 10%);
    
  &__screen {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: $color__gray;
  }
}

//= Header component =//
.header {
  background: lighten($color__gray, 5%);
  display: flex;
  padding: $spacing--sm;
  flex-direction: flex-row;
  justify-content: flex-end;
  position: relative;
  z-index: 2;
}

//= Subnav component =//
.sub-nav {
  display: block;
  height: $spacing--md;
  width: 100%;
  background: $color__gray--dark;
  position: relative;
  z-index: 2;
  box-shadow: 0 $spacing--sm/2 .15em rgba(0,0,0,.05);
}

//= Menu component =//
.menu {
  position: relative;
  z-index: 1;
  margin-top: -$spacing--md;  // allows the animation 'bounce' effect to not break
  border-bottom: $spacing--sm solid $color__base;
  box-shadow: 0 $spacing--sm/2 .15em rgba(0,0,0,.1);
  
  &__item { 
    font-family: 'Nunito', sans-serif;
    font-size: .8em;
    letter-spacing: .05em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
    color: #FFF;
    text-shadow: 0 .25em .25em rgba(0,0,0,.15);
    background: $color__base--dark;
    padding: $spacing--md*2 $spacing--md;
    width: 100%;
    
    &:first-of-type {
      padding: $spacing--md*3 $spacing--md; // allows the animation 'bounce' effect to not break
    }
  }
  
  &.is-collapsed {
    animation-name: slideUp;
    animation-duration: .5s;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
    transform: translateY(0%);
  }
  &.is-expanded {
    animation-name: slideDown;
    animation-duration: .5s;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
    transform: translateY(0%);
  }
}


//= Menu Button component =//
.menu-button {
  font-family: 'Nunito', sans-serif;
  text-align: center;
  background: $color__base;
  color: #FFF;
  text-shadow: 0 .2em .2em rgba(0,0,0,.2);
  height: 2.5em;
  width: 5em;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
  background: scale-color($color__base, $lightness: -50%);
  
  &__sub-container {
    height: 200%;
    
    &.is-menu-btn {
      animation-name: slideUpHalf;
      animation-duration: .5s;
      animation-timing-function: ease-in;
      animation-fill-mode: forwards;
      transform: translateY(-55%);
    }
    
    &.is-close-btn {
      animation-name: slideDownHalf;
      animation-duration: .5s;
      animation-timing-function: ease-in;
      animation-fill-mode: forwards;
      transform: translateY(0%);
    }
  }
  
  &__menu-state,
  &__close-state {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 50%;
  }
  
  &__menu-state {
    background: $color__base;
  }
  &__close-state {
    background: $color__base--dark;
  }
}

//= Content "component" =//
.content {
  margin-top: -75%; // prevents menu from pushing content down the page
  
  &__hero {
    display: block;
    margin-bottom: $spacing--md;
    width: 100%;
    background: darken($color__gray, 25%);
    height: $spacing--lg*6;
  }
  
  &__row {
    display: flex;
    align-items: center;
    justify-content: space-around;
  }
  
  &__block {
    background: #FFF;
    margin: $spacing--sm;
    width: 100%;
    height: $spacing--lg*4;
  }
}
            
          
!
            
              $('.menu-button').on('click', function() {
  var $menuButtonSubContainer = $(this).children('.menu-button__sub-container');
  var $menu = $('.menu');
  
  $('.is-menu-btn').on('click', function() {
    $menuButtonSubContainer.removeClass('is-menu-btn').addClass('is-close-btn');
    $menu.removeClass('is-collapsed').addClass('is-expanded');
  });
  
  $('.is-close-btn').on('click', function() {
    $menuButtonSubContainer.removeClass('is-close-btn').addClass('is-menu-btn');
    $menu.removeClass('is-expanded').addClass('is-collapsed');
  });
  
});


            
          
!
999px
Loading ..................

Console