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

Auto Save

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

              
                .block
  .tree
    .one
    .two
    .three
    .four
    .root
  .title Happy New Year!
              
            
!

CSS

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

$blue = #00A8FF
$red = #FF605F
$green = #96D100
$purple = #D066FA

*
  transition background .4s

body
  display flex
  justify-content center
  align-items center
  width 100vw
  height 100vh
  .block
    width 180px
    height 210px
    background transparent
    display flex
    flex-direction column
    justify-content space-between
    .tree
      width 100px
      height 140px
      background transparent
      margin-left 40px
      display flex
      flex-direction column
      align-items center
      mask url("http://frolovoleg.ru/images/tree.svg") no-repeat
      .one
        height 32px
        width 100%
        background $blue
        margin-bottom 2px
      .two
        height 23px
        width 100%
        background $red
        margin-bottom 2px
      .three
        height 28px
        width 100%
        background $green
        margin-bottom 2px
      .four 
        height 31px
        width 100%
        background $purple
        margin-bottom 2px
      .root
        height 18px
        width 6px
        background black
        opacity .2
    .title
      opacity .2
      align-self center
      font-size 22px
      font-family "Lato"
      font-weight 300
              
            
!

JS

              
                $(document).ready(function(){
  
  // Set time interval
  var timeInterval = 400
  
  // Time interval function. Each interaction it defines new colours for tree classes
  window.setInterval(differentBranges, timeInterval);
  
  // Set color function
  function randomColorForClass(className) {
    var randomNumber = Math.random();
    if (randomNumber >= 0 &&  randomNumber <= 0.25) {
      $(className).css("background", "#00A8FF");
      } else if (randomNumber > 0.25 && randomNumber <= 0.5) {
          $(className).css("background", "#FF605F");
      } else if (randomNumber > 0.5 && randomNumber <= 0.75) {
          $(className).css("background", "#96D100");
      } else {
          $(className).css("background", "#D066FA");
        };
     };
   
  // Define colours for tree classes
   function differentBranges() {   
     randomColorForClass(".one");
     randomColorForClass(".two");
     randomColorForClass(".three");
     randomColorForClass(".four");
   };
      
})


              
            
!
999px

Console