123

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <a href="#" class="button">SCSS Button</a>

<p class="note">I just discovered the beautiful 3d button created by <a href="https://blog.typekit.com/2011/02/10/type-study-an-all-css-button/">Dan Cederholm</a> and quickly wanted to convert it into a Sass mixin that can be used throughout my current project. As a simple addition I removed the dependency on the  span wrapper tag he decided to use.</p>
            
          
!
            
              @import "compass/css3";

/* Functions */

@function color-brightness($color) {
  @return ( 299 * red($color) + 587 * green($color) + 114 * blue($color) ) / 1000;
}

/* Mixins */

$button-text-color-light-default: #f1f1f1 !default;
$button-text-color-dark-default: #1a1a1a !default;
$button-background-color-default: #33bbff !default;
$button-contrast-treshold-default: 80 !default; // 125 is suggested by the w3c

@mixin button(
      $background-color: $button-background-color-default,
      $text-color-light: $button-text-color-light-default,
      $text-color-dark: $button-text-color-dark-default
){
  $text-color: if( abs(color-brightness($background-color) - color-brightness($text-color-light)) > $button-contrast-treshold-default, $text-color-light, $text-color-dark);
  $text-color-inverted: if($text-color == $text-color-light, $text-color-dark, $text-color-light);
  
  position: relative;
  display: inline-block;
  color: $text-color;
  outline: none;
  
  @include text-shadow(-1px -1px 0 transparentize($text-color-inverted, 0.5));
  @include background-with-css2-fallback( linear-gradient(darken($background-color, 5%), lighten($background-color, 5%)), $background-color );
  @include border-radius(6px);
  @include box-shadow(
    inset 0 -1px 1px lighten($background-color, 10%),
    0 8px 0 darken($background-color, 20%),
    0 10px 15px rgba(0, 0, 0, 0.35)
  );
  @include transition(all 100ms ease-in-out);
  
  &:hover {
    @include text-shadow(
      0 0 5px transparentize($text-color, 0.35), 
      -1px -1px 0 transparentize($text-color-inverted, 0.5)
    );
    @include background-with-css2-fallback( linear-gradient(darken($background-color, 3%), lighten($background-color, 8%)), lighten($background-color, 10%) );
    @include box-shadow(
      inset 0 -1px 1px lighten($background-color, 12%),
      0 8px 0 darken($background-color, 16%),
      0 10px 15px rgba(0, 0, 0, 0.35)
    );
  }
  
  &:active,
  &:focus {
    top: 4px;
    @include box-shadow(
      inset 0 -1px 1px lighten($background-color, 12%),
      0 5px 0 darken($background-color, 16%),
      0 6px 8px rgba(0, 0, 0, 0.35)
    );
  }
}

/* Styles */

@import url(https://fonts.googleapis.com/css?family=Lobster);

body {
  font: 16px/1.5em Arial, sans-serif;
  margin: 0 auto;
  padding: 3em 0 2em;
  max-width: 540px;
}

.note {
  margin: 3em 0 0 2em;
  padding: 0.5em 0 0.5em 2em;
  border-left: 1px solid #b3b3b3;
  color: #b3b3b3;
  
  a {
    color: #1a1a1a;
    text-decoration: none; 
  
    &:hover {
      border-bottom: 1px solid #33bbff;
    }
  }
}

.button {
  @include button(); /* Pass any colors you like, I hope the mixin will handle it */
  padding: 0.5em 1em;
  font: normal normal 3em/1 "Lobster", serif;

  text-decoration: none;
}
            
          
!
            
              /**
 * Note: To customize the button color pass a different background color to the 
 * mixin in line 86
 */
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console