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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <input id="toggle" type="checkbox">
<label for="toggle"></label>

<div class="demo-wrap">
  <div class="candle"></div>
  <div class="flicker"></div>
</div>
            
          
!
            
              // demonstration purposes only, please don't actually use these settings as this compiles to like over 2000 lines

$color-flame--base: #FEE3AC;
$flame-height--base: 80px;
$tolerance: .3;

$flickers: (
//    opacity : frequency
          0   :      100,
        .23   :       30,
        .45   :       90,
        .32   :       40
  
// Frequency is how many times the flame could possibly hit that opacity level for every 100 frames (increments of 10). Since the hitting is random, there is a great chance that keyframe percentages will be repeated.
// Keep in mind this compiles to over 2000 lines at its current settings. Try to keep your frequency below 50 for production.
  
);

.candle {
  width: 300px;
  height: 300px;
  margin: 0px auto;
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/155744/candle.jpg') no-repeat;
  background-size: contain;
  position: static;
  transition: .3s ease-in-out;
}
.demo-wrap {
  position: relative;
  width: 300px;
  margin: 0 auto;
  &:before, &:after {
    transition: .3s ease-in-out;
    opacity: 0;
    font-family: Helvetica;
    color: white;
    position: absolute;
  }
  &:before {
    top: 45%;
    left: -8%;
    content: 'image →';
    z-index: 1;
  }
  &:after {
    top: 25%;
    right: 27%;
    content: '← css';
  }
}
.flicker-wrap {
  transition: .3s ease-in-out;
}
.flicker {
  position: absolute;
  width: 10px;
  height: $flame-height--base;
  border-radius: 50%;
  top: 50px;
  left: 48%;
  background-color: $color-flame--base;
  box-shadow: 0 0 0px 0px $color-flame--base;
  -webkit-animation: 10s flicker infinite;
  animation: 10s flicker infinite;
  transition: .3s ease-in-out;
}
@keyframes flicker {
  $angle: 0;
  @each $level, $frequency in $flickers {
    @for $i from 1 through 100{ 
      @if $i % (floor(100 / $frequency)) == 0{
        $r: random(100);
        #{($r)}%{
          $amount: floor($i / 10); 
          $color-flame: darken($color-flame--base, $amount);
          opacity: $level;
          $f-blur: $i * .33;
          $f-spread: $f-blur * .5;
          box-shadow: 0 0 #{$f-blur}px #{$f-spread}px $color-flame;
          @if $i % 2 == 0{
            $angle: $amount / 2;
          }
          @else{
            $angle: 0 - $amount / 2;
          }
          @if $level <= $tolerance {
            height: 0;
          }
          @else if $level <= ($tolerance - $flame-height--base * .1){
            height: ( ($flame-height--base - $flame-height--base * .1) - 2 * $amount);
          }
          @else{
            height: ( $flame-height--base - 2 * $amount);
          }
          -webkit-transform: rotate(#{$angle}deg);
          transform: rotate(#{$angle}deg);
        }
      }
    }
  }
}

// Demo controls
label {
  position: fixed;
  top: 230px;
  z-index: 100;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 120px;
  text-align: center;
  font-family: Helvetica;
  color: #FFF;
  padding: 10px;
  background-color: #676767;
  cursor: pointer;
  border-radius: 4px;
  &:after{
    content: 'separate';
  }
  &:hover{
    background-color: lighten(#676767,5%);
  }
}
input{
  display: none;
  &:checked{
    + label {
      &:after{
        content: 'combine';
      }
    }
    ~ .demo-wrap .candle {
      transform: translateX(-25%);
    }
    ~ .demo-wrap {
      &:before, &:after {
        opacity: 1;
      }
    }
  }
}
body {
  background-color: #000;
  text-align: center;
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console