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

              
                label.switch
  input(type='checkbox' checked)
  .button
    .light
    .dots
    .characters
    .shine
    .shadow
              
            
!

CSS

              
                $color: #ff1818; // Try other colors, like #18ffa0
$rotation: 25deg;
$pivot-distance: 20px;
$width: 150px;
$height: 1.3 * $width;

body, html {
  width: 100%;
  height: 100%;
}

body {
  background-color: #fafcff;
  background-image: radial-gradient(circle, transparent, #afb5bf), linear-gradient(transparent, #d3d8e0);
  display: flex;
  align-items: center;
  justify-content: center;
}

.switch {
  background-color: black;
  width: $width;
  height: $height;
  box-shadow: 
    0 0 10px 2px rgba(black, 0.2), // The surrounding shadow (first layer)
    0 0 1px 2px black, // The surrounding shadow (second layer)
    inset 0 2px 2px -2px white, // The top white "shine"
    inset 0 0 2px 15px #47434c, // The light gray frame
    inset 0 0 2px 22px black; // The internal black shadow
  border-radius: 5px;
  padding: 20px;
  perspective: 700px;
  
  input {
    display: none;
    
    &:checked + .button {
      transform: translateZ($pivot-distance) rotateX($rotation);
      box-shadow: 0 -10px 20px $color;
      
      .light {
        animation: flicker 0.2s infinite 0.3s;
      }
      
      .shine {
        opacity: 1;
      }
      
      .shadow {
        opacity: 0;
      }
    }
  }
  
  .button {
    transition: all 0.3s cubic-bezier(1, 0, 1, 1);
    transform-origin: center center -#{$pivot-distance};
    transform: translateZ($pivot-distance) rotateX(-$rotation);
    transform-style: preserve-3d;
    background-color: #9b0621;
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
    background: linear-gradient(darken($color, 25%) 0%, darken($color, 33%) 30%, darken($color, 33%) 70%, darken($color, 25%) 100%);
    background-repeat: no-repeat;
    
    &::before {
      content: "";
      background: linear-gradient(rgba(white, 0.8) 10%, rgba(white, 0.3) 30%, darken($color, 35%) 75%, darken($color, 45%)) 50% 50% / 97% 97%, darken($color, 20%);
      background-repeat: no-repeat;
      width: 100%;
      height: 50px;
      transform-origin: top;
      transform: rotateX(-90deg);
      position: absolute;
      top: 0;
    }
    
    &::after {
      content: "";
      background-image: linear-gradient(darken($color, 35%), darken($color, 45%));
      width: 100%;
      height: 50px;
      transform-origin: top;
      transform: translateY(50px) rotateX(-90deg);
      position: absolute;
      bottom: 0;
      box-shadow: 0 50px 8px 0px black, 0 80px 20px 0px rgba(black, 0.5);
    }
  }
  
  .light {
    opacity: 0;
    animation:  light-off 1s;
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
      // We use adjust-hue() here to make the center of the light a bit different in color
      // This is a nice tool for visualizing it https://sassme.jim-nielsen.com/
      radial-gradient(adjust-hue(lighten($color, 20%), 35), $color 40%, transparent 70%);
  }
  
  .dots {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(transparent 30%, rgba(darken($color, 35%), 0.7) 70%);
    background-size: 10px 10px;
  }
  
  .characters {
    position: absolute;
    width: 100%;
    height: 100%;
    
    // Drawing with gradients!
    // Read more about it here: https://css-tricks.com/drawing-images-with-css-gradients/
    // And check this collection out: https://a.singlediv.com/
    background:
      linear-gradient(white, white) 50% 20% / 5% 20%, // White vertical line
      radial-gradient(circle, transparent 50%, white 52%, white 70%, transparent 72%) 50% 80% / 33% 25%; // White circle
    background-repeat: no-repeat;
  }
  
  .shine {
    transition: all 0.3s cubic-bezier(1, 0, 1, 1);
    opacity: 0.3;
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
      linear-gradient(white, transparent 3%) 50% 50% / 97% 97%,
      linear-gradient(rgba(white, 0.5), transparent 50%, transparent 80%, rgba(white, 0.5)) 50% 50% / 97% 97%;
    background-repeat: no-repeat;
  }
  
  .shadow {
    transition: all 0.3s cubic-bezier(1, 0, 1, 1);
    opacity: 1;
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
      linear-gradient(transparent 70%, rgba(black, 0.8));
    background-repeat: no-repeat;
  }
}

@keyframes flicker {
  0% {opacity: 1}
  80% {opacity: 0.8}
  100% {opacity: 1}
}

@keyframes light-off {
  0% {opacity: 1}
  80% {opacity: 0}
}
              
            
!

JS

              
                
              
            
!
999px

Console