Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                %div#wrapper
  %div#header
    %div#header--container
      %h1#title
        Sweet and Simple Buttons
      %center
        Easily create fun effects for your buttons
        %br
        %small
          Created by 
          %a{:href => "https://twitter.com/MmmmGravy", :target => "_blank"} Shawn G.
      %div.header--scroll-wrapper
        %a.button.red.secondary-white.animation-uncover-down{:href => "#colors"}
          %span But Wait, There's More!
  %div#content
    %div.container
      %section
        %h1 
          %a{:name => "colors"} Colors

        %h2
          Default 
          %small (No animation effects or secondary colors)
        %div
          %button.grey
            %span
              Grey Button 
              %small (default)
          %button.white
            %span White Button
          %button.red
            %span Red Button
          %button.orange
            %span Orange Button
          %button.yellow
            %span Yellow Button
          %button.green
            %span Green Button
          %button.blue
            %span Blue Button
          %button.dark-blue
            %span Dark Blue Button
          %button.purple
            %span Purple Button
        %h2
          Secondary Colors 
          %small (No animation effects and default color)
        %div
          %button.secondary-white
            %span White Button
          %button.secondary-red
            %span Red Button
          %button.secondary-orange
            %span Orange Button
          %button.secondary-yellow
            %span Yellow Button
          %button.secondary-green
            %span Green Button
          %button.secondary-blue
            %span Blue Button
          %button.secondary-dark-blue
            %span Dark Blue Button
          %button.secondary-purple
            %span Purple Button
          %p Mix and match colors to create sweet combinations
          %button.white.secondary-purple
            %span White Button
          %button.red.secondary-dark-blue
            %span Red Button
          %button.orange.secondary-blue
            %span Orange Button
          %button.yellow.secondary-green
            %span Yellow Button
          %button.green.secondary-yellow
            %span Green Button
          %button.blue.secondary-orange
            %span Blue Button
          %button.dark-blue.secondary-red
            %span Dark Blue Button
          %button.purple.secondary-white
            %span Purple Button
          %p
            %small
              Eight of 28 combinations! 
              %a{:href => "#build-your-own"}Add more colors for more combinations!
      %section
        %h1 
          %a{:name => "animations"} Animations
        %div
          %button.grey.animation-slide-down
            %span Slide Down
          %button.red.animation-slide-up
            %span Slide Up
          %button.orange.animation-slide-left
            %span Slide Left
          %button.yellow.animation-slide-right
            %span Slide Right
          %button.green.animation-zoom-in
            %span Zoom In
          %button.blue.animation-zoom-out
            %span Zoom Out
          %button.dark-blue.animation-uncover-up
            %span Uncover Up
          %button.purple.animation-uncover-down
            %span Uncover Down
          %p Mix and match colors here to to create some cool animations
          %button.white.secondary-purple.animation-slide-down
            %span Slide Down
          %button.red.secondary-dark-blue.animation-slide-up
            %span Slide Up
          %button.orange.secondary-blue.animation-slide-left
            %span Slide Left
          %button.yellow.secondary-green.animation-slide-right
            %span Slide Right
          %button.green.secondary-yellow.animation-zoom-in
            %span Zoom In
          %button.blue.secondary-orange.animation-zoom-out
            %span Zoom Out
          %button.dark-blue.secondary-red.animation-uncover-up
            %span Uncover Up
          %button.purple.secondary-white.animation-uncover-down
            %span Uncover Down
      %section
        %h1 
          %a{:name => "sizes"} Sizes
        %div
          %button.largest
            %span button.largest
          %button.larger
            %span button.larger
        %div
          %button.large
            %span button.large
          %button.normal
            %span button.normal
        %div
          %button.small
            %span button.small
          %button.smaller
            %span button.smaller
        %div
          %button.smallest
            %span button.smallest
      %section
        %h1 
          %a{:name => "how-to-use"} How to Use
        %div.grey
          %pre
            = preserve do
              :escaped
                <button class="{color} {hover-color} {animation-type}">
                  <span>Text Here</span>
                </button>
      %section
        %h1 
          %a{:name => "build-your-own"} Build Your Own

        %h2 Colors
        Using SASS or SCSS add the following to the $button--colors map
        %div.grey
          %pre
            = preserve do
              :escaped
                {color-name}: (
                    text: {text-color},
                    background: {background-color}
                )

        %h2 Animations
        Using SASS or SCSS add the following to the $button--animations map
        %div.grey
          %pre
            = preserve do
              :escaped
                {animation-name}: (
                  before: (
                    default: (
                      {default styles here}
                    ),
                    hover: (
                      {hover styles here}
                    )
                  ),
                  after: (
                    default: (
                      {default styles here}
                    ),
                    hover: (
                      {hover styles here}
                    )
                  )
                )

        %h2 Sizes
        Using SASS or SCSS add the following to the $button--sizes map
        %div.grey
          %pre
            = preserve do
              :escaped
                {size-name}: {size-value}
        %div
          %center
            %small
              Background image from wallpaperstock.net
            %br
            %small
              Created by 
              %a{:href => "https://twitter.com/Shawn_Sauce", :target => "_blank"} Shawn G.
            %br
            %small
              %a{:href => "https://codepen.io/ShawnSauce/pen/ogjaby", :target => "_blank"} permalink
              
            
!

CSS

              
                $button--colors: (
  grey: (text: #333, background: #bdc3c7),
  white: (text: #333, background: #fff),
  red: (text: #fff, background: #c0392b),
  orange: (text: #fff, background: #e67e22),
  yellow: (text: #fff, background: #f1c40f),
  green: (text: #fff, background: #27ae60),
  blue: (text: #fff, background: #446CB3),
  dark-blue: (text: #fff, background: #2c3e50),
  purple: (text: #fff, background: #8e44ad)
);

$button--colors-default: map-get($button--colors, grey);
$button--sizes-default: 24px;

$button--sizes: (
  smallest: $button--sizes-default - 12,
  smaller: $button--sizes-default - 8,
  small: $button--sizes-default - 4,
  normal: $button--sizes-default,
  large: $button--sizes-default + 4,
  larger: $button--sizes-default + 8,
  largest: $button--sizes-default + 12
);

$button--animations: (
  slide-down: (
    after: (
      default: (
        transition: height .2s ease-in-out,
        top: 0,
        height: 0%
      ),
      hover: ( height: 100% )
    )
  ),
  slide-up: (
    after: (
      default: (
        transition: height .2s ease-in-out,
        top: auto,
        bottom: 0,
        height: 0%
      ),
      hover: ( height: 100% )
    )
  ),
  slide-left: (
    after: (
      default: (
        transition: width .2s ease-in-out,
        left: 0,
        width: 0
      ),
      hover: ( width: 100% )
    )
  ),
  slide-right: (
    after: (
      default: (
        transition: width .2s ease-in-out,
        left: auto,
        right: 0,
        width: 0%
      ),
      hover: ( width: 100% )
    )
  ),
  zoom-in: (
    after: (
      default: (
        transition: transform .2s ease-in-out,
        transform: scale(0)
      ),
      hover: ( transform: scale(1) )
    )
  ),
  zoom-out: (
    before: (
      default: (
        transition: transform .2s ease-in-out,
        transform: scale(1),
        z-index: 2
      ),
      hover: ( transform: scale(0),z-index: 1 )
    )
  ),
  uncover-up: (
    before:(
      default: (
        transition: transform .2s ease-out,
        transform: rotateX(0deg) translateZ(0),
        transform-origin: top center,
        z-index: 2
      ),
      hover: ( transform: rotateX( 95deg ) translateZ(0) )
    ),
    after: (
      default: (z-index:1)
    )
  ),
  uncover-down: (
    before:(
      default: (
        transition: transform .2s ease-in,
        transform: rotateX(0deg) translateZ(0),
        transform-origin: bottom center,
        z-index: 2
      ),
      hover: ( transform: rotateX( -95deg ) translateZ(0) )
    ),
    after: (
      default: (z-index:1)
    )
  )
);


button, .button {
  display: inline-block;
  position: relative;
  cursor: pointer;
  
  margin: 10px;
  
  user-select: none;
  text-decoration: none;
  
  perspective: 800px;
  
  border: none;
  background: none;
  color: map-get($button--colors-default, text);
  
  font-size: $button--sizes-default;
  padding: $button--sizes-default/1.5;
  
  transition: color .25s;
  
  &:after {
    opacity: 0;
    
    transition: all .25s;
    
    background: lighten(map-get($button--colors-default, background), 10)
  }
  
  &:before {
   background: map-get($button--colors-default, background);
  }
  
  &:hover {
    &:after {
      opacity: 1;
    }
  }
  
  > span {
    position: relative;
    z-index: 2;
  }
  
  @each $color-name, $current-list in $button--colors {
    $background-color: map-get($current-list, background);
    $text-color: map-get($current-list, text);
    &.#{$color-name}{
      color: $text-color;
      &:before {
        background: $background-color;
      }
      &:after {
        background: lighten($background-color,10);
      }
    }
    &.secondary-#{$color-name}{
      &:hover {
        color: $text-color !important;
      }
      &:after {
        background: $background-color !important;
      }
    }
  }
  
  @each $anim-name, $anim-list in $button--animations {
    &.animation-#{$anim-name} {
      
      // Clear transitions from default animation
      &:after {
        transition: none;
        opacity: 1;
      }
      
      @each $pseudo-type, $pseudo-list in $anim-list {
        
        &:#{$pseudo-type} {
          @each $css-key, $css-value in map-get($pseudo-list, default) {
            #{$css-key}: $css-value;
          }
        }
        @each $pseudo-key, $pseudo-css-list in $pseudo-list {
          @if $pseudo-key != default {
            &:#{$pseudo-key}:#{$pseudo-type} {

              @each $css-key, $css-value in $pseudo-css-list {
                #{$css-key}: $css-value;
              }
            }
          }
        }
      }
    }
  }
  
  @each $size-name, $font-size in $button--sizes {
    &.#{$size-name} {
      font-size: $font-size;
      padding: $font-size/1.5;
    }
  }
  
  &:before, &:after {
    position: absolute;
    top: 0;
    left: 0;
    
    content: "";
    
    width: 100%;
    height: 100%;
    
  }
}
















/** Demo Page Styling **/
*{ font-family: 'PT Sans', sans-serif; }

html, body {
  min-height: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}

body {
  background: url(http://img.wallpaperstock.net:81/blurred-nature-scenery-wallpapers_35218_1366x768.jpg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  
  font-family: 'PT Sans', sans-serif;
}

div#wrapper {
  position: relative;
  min-height: 100%;
  height: 100%;
}

div#header {
  position: relative;
  min-height: 525px;
  
  
  background: rgba(0,0,0,.3);
  
  small {
    color: #fff;
    a {
      color: #fff;
    }
  }
  
  div#header--container {
    width: 650px;
    
    color: #fff;
    
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    
    .header--scroll-wrapper {
      padding: 50px 0;
      text-align: center;
    }
  }
  h1#title {
    font-size: 3em;

    color: #fff;
    text-shadow:
      0 3px 12px rgba(0,0,0,.6);
    
    text-align: center;

    margin: 0 0 20px 0;
    
    opacity: .8;
  }
}

div.container {
  max-width: 650px;
  margin: 0 auto;
  padding: 20px 0;
}



div#content {
  background: #fff;
  
  section{
    margin: 0 0 100px 0;
    > h1 {
      font-size: 3em;
    }
    small {
      color: #000;
      opacity: .6;
      a {
        color: #000;
      }
    }
    > div {
      border-radius: 4px;
      padding: 10px;
      &.grey {
        background: #ddd;
      }
    }
  }
}
              
            
!

JS

              
                /** Demo Page JavaScript **/
; (function(){
  
  document.body.className = 'parallax';

  var parallax = document.querySelectorAll(".parallax"),
      speed = 0.5;

  window.onscroll = function(){
    [].slice.call(parallax).forEach(function(el,i){

      var windowYOffset = window.pageYOffset,
          elBackgrounPos = "50% " + (windowYOffset * speed) + "px";
      
      el.style.backgroundPosition = elBackgrounPos;

    });
  };

 
  
  var win = $(window),
      header = $('#header');
  
  win
  .on( 'resize' , function(){
    header.css('height', win.height() + 'px')
  })
  .trigger( 'resize' )
  .trigger( 'scroll' );
})();
              
            
!
999px

Console