Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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 class="container">
  <div class="layer filter">
    
  </div>
  <div class="layer sunset">
    <div class="text">Sunset</div>
  </div>
  <div class="layer nighttime">
    <div class="text">Night</div>
  </div>
  <div class="layer stars">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
  </div>
  <div class="note">
    Click to shift between Sunset and Night.
  </div>
</div>


              
            
!

CSS

              
                html,body{
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  background: #eee;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: Arial, Helvetica, Sans-serif;
}

.container{
  display: flex;
  width: 100%;
  height: 100%;
  background: white;
  position: relative;
  cursor: pointer;
  .layer{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: all 4s ease;
    opacity: 0.5;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 100%;
    overflow: hidden;
    &>div.text{
      display: flex;
      text-align: center;
      color: white;
      
      font-size: 36px;
      width: 50%;
      height: 50%;
      justify-content: center;
      align-items: center;
      transition: transform 4s ease, opacity 1.5s linear;
    }
    &.filter{
      background: linear-gradient(0deg, violet, #048);
    }
    &.sunset{
      background: linear-gradient(0deg, orange, blue);
      opacity: 0.5;
      &>div{
        transform: translateY(0%);
        opacity: 1;
      }
    }
    &.nighttime{
      background: linear-gradient(0deg, #04A, #000);
      opacity: 0;
      &>div{
        transform: translateY(-100%);
        opacity: 0;
      }
    }
    &.stars{
      opacity: 0.1;
      transition: opacity 4s ease, transform 4s;
      transform: translateY(-5%);
      &>div{
        transition: transform 0s;
        position: absolute;
        top: 0;
        left: 0;
        width: 3px;
        height: 3px;
        border-radius: 2px;
        background: white;
        box-shadow: 0 0 2px white;
        @for $i from 1 through 50{
          &:nth-child(#{$i}){
            transform: translateX(random(2200) + px) translateY(random(400) + px) scale(random(10)/7);
            box-shadow: 0 0 random(4)+px white;
            opacity: random(10)/10;
          }
        }
      }
    }
  }
  
  .note{
    padding: 20px;
    border: solid 1px white;
    width: 33.333%;
    color: white;
    text-align: center;
    font-size: 16px;
    position: absolute;
    bottom: 15px;
    left: 33.333%;
    background: rgba(125, 95, 85, 0.4);
    text-shadow: 0 1px 1px black;
    border-radius: 30px;
    transition: background 4s ease;
  }
  
  &.night{
    .layer:nth-child(2){
      opacity: 0;
      &>div{
        transform: translateY(100%);
        opacity: 0;
      }
    }
    .layer:nth-child(3){
      opacity: 0.8;
      &>div{
        transform: translateY(0%);
        opacity: 1;
      }
    }
    .layer.stars{
      opacity: 1;
      transform: translateY(0%);
      transition: opacity 8s ease, transform 15s ease;
    }
    .note{
      background: rgba(100, 100, 122, 0.02);
    }
  }
  
  
}

              
            
!

JS

              
                document.querySelector('.container').addEventListener('click', function(){
  this.className = (this.className === 'container night' ? 'container' : 'container night');
})
              
            
!
999px

Console