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

              
                <canvas class="tree" width="500" height="500"></canvas>
<div class="noise"></div>
<div class="ground">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1921 173"><path d="M.5,130.7s663-98,960,0,961-130,961-130v173H.5Z" transform="translate(-0.5 -0.7)" style="fill:snow"/></svg>
</div>
<div class="sun"></div>
<div class="snow"></div>
<div class="cloud cloud--small">
  <div class="cloud-outer"></div>
</div>
<div class="cloud cloud--medium">
  <div class="cloud-outer"></div>
</div>
<div class="cloud cloud--large">
  <div class="cloud-outer"></div>
</div>
<a class="post" href="https://supremo.co.uk" target="_blank">
  <h1 class="post__merry">Merry Christmas</h1>
  <h2 class="post__from">From</h2>
  <svg class="post__logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 807.85 264.73"><path d="M34.6,67.2c0-26.36,19.87-43.85,44.6-43.85,20.28,0,36,17,36,38.66,0,16.48-6.38,29.93-11.11,36.49,18.26-.67,44.28-16.8,44.28-46.81C148.32,26,125,0,80.22,0,33.08,0,0,33.55,0,67.2c0,70.71,84.09,75.56,84.09,113,0,17.87-13.15,29.18-32.13,29.18s-32.18-14.26-29.24-46.35C13.36,164.8.44,176,.44,190.94c0,24.63,20,42.52,50.21,42.52,31.75,0,63.11-21.48,63.11-56.52,0-61.06-79.16-65-79.16-109.74" style="fill:#ff360d"/><path d="M802.9,116.73c-4.87,8.24-38.38,20.59-57.84,19.18-1.92-14.9-9.53-33.52-25.71-33.52A16.54,16.54,0,0,0,703,119.31c0,14.37,7.79,26.23,21.48,33-1.9,17.06-13.8,37.92-27.56,37.92-23.55,0-16.44-59,.55-76-1.84-2.66-7.62-5.12-12.69-5.12-14.85,0-34.27,21.08-34.27,50.24,0,9.44-4.54,28.28-13.25,28.28s-1.49-33-1.49-55.48c0-15.4-8.72-23.5-19.52-23.5-9.91,0-20.08,5.58-29,16-2.52-7.45-8.84-15.27-19.75-15.27-12.22,0-19,5.84-26.92,17.63.71-23.06-19.2-19.91-29.26-12.32,1.49,4,2.07,9.14,1.34,17.79-2.79,33.4-30.56,60.14-51.87,60.14-9.23,0-15.1-4-17.07-16.12,28,1.18,52.24-18.69,52.24-41.08,0-16.83-14.46-28.73-34.22-28.73-26.53,0-50.08,26.53-50.08,56.31a61.4,61.4,0,0,0,1,10.76c-5.61,9.5-13.79,18.23-20.47,15.94-3.19-1.09-4-9.33,5.31-33.84,2.16-5.7,9-21.78-8.6-24.34-10.78-1.57-18.11-3.29-24.49-5.6,2.56-17.06-7.53-22.21-14.67-22.21-9.69,0-17.56,8.57-17.56,19.37,0,9.67,3.92,18.63,11.46,22.54-6.8,15.78-18.27,31.45-34.7,40.63a64.08,64.08,0,0,0,14.45-41.37c0-21.23-14.63-35.5-32.56-35.5-15.41,0-23,6.9-30.84,18.24-2-24.94-26-18.73-30.83-15.31,3.29,8.66,3.54,21.92,2.41,36.89-1.58,19.52-14.5,38.68-22.35,38.68s2.94-35.5,2.94-60.43c0-26.67-23.61-19.35-31.48-14.59a80.91,80.91,0,0,1,1.6,17.83c0,31.25-12.93,56.64-23,56.64-12.26,0-2.93-45.11-2.93-59.47,0-26-26.53-18.48-31.28-15,7.5,9.7-2.38,45-2.38,65.28,0,22.18,8,32.61,24.51,32.61,11.28,0,24.59-7.58,31.86-21.56,3.52,12.06,9.73,20.64,20.29,20.64,8.68,0,18.25-5.48,27.3-20.5-2.84,19.16-5.71,37.23-5.71,49.05,0,16.5,4.76,26.33,19.15,26.33a65.18,65.18,0,0,0,16.17-2.37c-10.25-20.31-2.46-63.52,1.5-92,4.07-29.35,14.12-41.83,24.73-41.83,6,0,11.14,6.58,11.14,17.38,0,31.51-15.42,49.88-31.52,48.24-2.2,7.5-2.3,16.28,16.92,16.28,37.46,0,65.9-30.36,78.42-59.19a90.26,90.26,0,0,0,12.84,2.17c-4.07,9.74-9.56,23.72-9.56,36.71,0,9.7,3.11,21.23,19.76,21.23,11.67,0,26.75-9.09,36.49-23.4,8,17.25,23.91,23.36,38.53,23.36,19.53,0,38.42-11.21,51.86-33.66-1.28,13.79-.19,32.78,14.37,32.78a26.6,26.6,0,0,0,13.36-3.84c-2.56-29.09,6.22-75.93,22.87-75.93,10.8,0,.73,29.85.73,48.51,0,14.6.79,31.29,18.49,31.29a41.3,41.3,0,0,0,11.64-1.73c-1.94-6.79-2.39-13.11-2.39-21.94,0-25.9,5.23-54.32,17.14-54.32,9.5,0,3.75,23,3.75,46.33s5.75,31.72,20.23,31.72c12.56,0,22.58-10.51,28.12-23.16,7.53,16.63,21.69,22.77,32.45,22.77,33.09,0,50.89-27.14,55.9-52.19a82.88,82.88,0,0,0,9.91.59c31.54,0,67.16-12.29,48.94-41.77M465,125.56c7.13,0,8.67,4.94,8.67,9,0,13.82-11.5,27.93-30.73,28.24C443.72,141,457,125.56,465,125.56" style="fill:#ff360d"/></svg>
  <svg class="grass grass--one" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 27.69"><path d="M20,18.71a.37.37,0,0,0-.49-.22l-4.59,1.72,5-5.73a.38.38,0,1,0-.57-.5l-3,3.41.57-2.3a.38.38,0,0,0-.28-.46.39.39,0,0,0-.47.28l-.93,3.75-3.94,4.51-.37-6.12,2.69-3.2h2.16a.36.36,0,0,0,.27-.12l2.31-2.3a.39.39,0,1,0-.55-.55l-2.19,2.2H14.26l3.34-4a.37.37,0,0,0-.05-.54.38.38,0,0,0-.54,0l-6.16,7.34-.19-3.09,4.61-4.5a.39.39,0,1,0-.54-.55l-4.13,4L10.43,9,16,3.74a.38.38,0,1,0-.52-.56L13.2,5.35l-.11-1,.72-1.44a.38.38,0,0,0-.18-.51.37.37,0,0,0-.51.17l-.77,1.54a.38.38,0,0,0,0,.21L12.5,6,10.37,8l-.19-3.13,1.23-1.12a.41.41,0,0,0,.13-.29V.38a.39.39,0,0,0-.77,0V3.29l-.65.6L10,1.9a.37.37,0,0,0-.41-.36A.38.38,0,0,0,9.23,2L10,13.81,7.47,12l1-3.78a.39.39,0,0,0-.28-.47A.4.4,0,0,0,7.7,8l-.9,3.47-1.11-.83L6.14,9a.4.4,0,0,0,0-.32L4.55,6.33a.38.38,0,0,0-.64.42L5.35,8.92,5,10.12,2.92,8.54a.38.38,0,0,0-.54.08.38.38,0,0,0,.08.53L5,11.07H5l5,3.75L10.14,17h0l.25,4L5.93,16.77l.22-4.06a.38.38,0,0,0-.76,0l-.19,3.4L3,14a.39.39,0,1,0-.53.56l1.11,1.06L.41,15.39a.36.36,0,0,0-.41.36.38.38,0,0,0,.36.4l4.05.24L8.23,20H3.55l-3-1.5a.39.39,0,0,0-.52.17.39.39,0,0,0,.17.52l3.08,1.54a.47.47,0,0,0,.17,0H9l1.41,1.34.13,2h0l.19,3.18a.38.38,0,0,0,.38.36h0a.38.38,0,0,0,.36-.41l-.19-3,2.47-2.82,5.93-2.23A.38.38,0,0,0,20,18.71Z" style="fill:#515151"/></svg>
  <svg class="grass grass--two" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 27.69"><path d="M20,18.71a.37.37,0,0,0-.49-.22l-4.59,1.72,5-5.73a.38.38,0,1,0-.57-.5l-3,3.41.57-2.3a.38.38,0,0,0-.28-.46.39.39,0,0,0-.47.28l-.93,3.75-3.94,4.51-.37-6.12,2.69-3.2h2.16a.36.36,0,0,0,.27-.12l2.31-2.3a.39.39,0,1,0-.55-.55l-2.19,2.2H14.26l3.34-4a.37.37,0,0,0-.05-.54.38.38,0,0,0-.54,0l-6.16,7.34-.19-3.09,4.61-4.5a.39.39,0,1,0-.54-.55l-4.13,4L10.43,9,16,3.74a.38.38,0,1,0-.52-.56L13.2,5.35l-.11-1,.72-1.44a.38.38,0,0,0-.18-.51.37.37,0,0,0-.51.17l-.77,1.54a.38.38,0,0,0,0,.21L12.5,6,10.37,8l-.19-3.13,1.23-1.12a.41.41,0,0,0,.13-.29V.38a.39.39,0,0,0-.77,0V3.29l-.65.6L10,1.9a.37.37,0,0,0-.41-.36A.38.38,0,0,0,9.23,2L10,13.81,7.47,12l1-3.78a.39.39,0,0,0-.28-.47A.4.4,0,0,0,7.7,8l-.9,3.47-1.11-.83L6.14,9a.4.4,0,0,0,0-.32L4.55,6.33a.38.38,0,0,0-.64.42L5.35,8.92,5,10.12,2.92,8.54a.38.38,0,0,0-.54.08.38.38,0,0,0,.08.53L5,11.07H5l5,3.75L10.14,17h0l.25,4L5.93,16.77l.22-4.06a.38.38,0,0,0-.76,0l-.19,3.4L3,14a.39.39,0,1,0-.53.56l1.11,1.06L.41,15.39a.36.36,0,0,0-.41.36.38.38,0,0,0,.36.4l4.05.24L8.23,20H3.55l-3-1.5a.39.39,0,0,0-.52.17.39.39,0,0,0,.17.52l3.08,1.54a.47.47,0,0,0,.17,0H9l1.41,1.34.13,2h0l.19,3.18a.38.38,0,0,0,.38.36h0a.38.38,0,0,0,.36-.41l-.19-3,2.47-2.82,5.93-2.23A.38.38,0,0,0,20,18.71Z" style="fill:#515151"/></svg>
</a>
              
            
!

CSS

              
                /*
  > Zdog Christmas scene.
  > Merry Christmas!
  > Made by Supremo
*/

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(0deg, rgba(157,221,255,1) 50%, rgba(63,188,238,1) 100%);
}

.tree {
  z-index: 3;
  cursor: move;
}

.ground {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 50%;
  background: #fffafa;
  z-index: 1;
}

.ground svg {
  width: 100%;
  height: auto;
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
}

.sun {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: #FFEAB1;
}

.cloud {
  position: absolute;
  width: 220px;
  height: 35px;
  background: #fff;
  border-radius: 20px;
  will-change: transform;
  
  &--small {
    top: 15%;
    left: 16%;
    transform: scale(0.7);
    opacity: .7;
    animation: cloudSmall 160s linear;
    animation-fill-mode: forwards;
  }

  &--medium {
    top: 22%;
    left: -100px;
    opacity: .9;
    animation: cloudMedium 120s linear;
    animation-fill-mode: forwards;
  }
  
  &--large {
    top: 25%;
    left: 60%;
    animation: cloudLarge 80s linear;
    animation-fill-mode: forwards;
  }
  
  &:before {
    content: '';
    position: absolute;
    width: 100px;
    height: 35px;
    background: #fff;
    border-radius: 20px;
    transform: translate(20px, -55%);
  }

  &:after {
    content: '';
    position: absolute;
    width: 125px;
    height: 35px;
    background: #fff;
    border-radius: 20px;
    transform: translate(60px, 58%);
  }
}

.cloud-outer {
  position: absolute;
  top: 20%;
  left: 20%;
  width: 75px;
  height: 20px;
  background: #fff;
  border-radius: 20px;
  transform: translate(90px, -40px);
}

@font-face {
  font-family: "FreightDisplayPro";
  src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/2101521/Freight%20Display%20Pro%20Bold.otf");
}

.post {
  position: absolute;
  text-align: center;
  top: 48%;
  left: 58%;
  background: #fff;
  padding: 35px;
  z-index: 5;
  transform: rotate(3deg);
  transform-style: preserve-3d;
  
  &:before {
    content: '';
    position: absolute;
    width: 15px;
    height: 350px;
    top: -15px;
    background: #966F33;
    z-index: -1;
    transform: translateZ(-1px) rotate(-3deg);
  }

  &__merry {
    font-family: 'FreightDisplayPro', serif;
    font-weight: normal;
    font-size: 32px;
    color: #252529;
  }

  &__from {
    font-family: 'Karla', sans-serif;
    font-size: 12px;
    color: #A1A1A1;
  }

  &__logo {
    width: 90px;
  }
}

.grass {
  position: absolute;
  
  &--one {
    bottom: -190px;
    height: 58px;
    width: 50px;
    transform: rotate(8deg);
    left: 150px;
  }

  &--two {
    bottom: -205px;
    height: 65px;
    width: 57px;
    transform: rotate(-14deg);
    left: 115px;
  }
}

.noise,
.snow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
}

.noise {
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/2101521/noise.png');
  background-repeat: repeat;
  background-size: auto;
  z-index: 2;
}

.snow {
  pointer-events: none;
  z-index: 4;
}

.snow__particle {
  width: 35px;
  height: 35px;
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/2101521/snow.png');
  background-size: 30% 30%;
  background-repeat: no-repeat;
}

@keyframes cloudSmall {
  0% {
    transform: translateX(0) scale(0.7);
  }
  100% {
    transform: translateX(100vw) scale(0.7);
  }
}

@keyframes cloudMedium {
  0% {
    transform: translateX(0) scale(0.9);
  }
  100% {
    transform: translateX(105vw) scale(0.9);
  }
}

@keyframes cloudLarge {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(100vw);
  }
}

a {
  color: inherit;
  text-decoration: none;
}
              
            
!

JS

              
                // Tree colour variables
var green1 = '#51cf66';
var green2 = '#40c057';
var green3 = '#37b24d';
var green4 = '#2f9e44';
var green5 = '#2b8a3e';
var trunk = '#966F33';
var trunkBottom = '#654321'
const TAU = Zdog.TAU;

// Create the illustration
var illo = new Zdog.Illustration({
  element: '.tree',
  dragRotate: true,
  scale: 1.5,
  rotate: { x: -TAU/16 },
});

// Tree Anchor
var treeAnchor = new Zdog.Anchor({
  addTo: illo,
  translate: { y: 24 },
  rotate: { x: TAU/4 },
});

// Top layer of the tree
var tree = new Zdog.Cone({
  addTo: treeAnchor,
  diameter: 60,
  length: 50,
  stroke: false,
  translate: { z: 50 },
  color: green1,
  backface: green5,
});

// 2nd layer of the tree
var tree2 = new Zdog.Cone({
  addTo: treeAnchor,
  diameter: 80,
  length: 50,
  stroke: false,
  translate: { z: 25 },
  color: green2,
  backface: green5,
  rotate: { z: TAU/6 },
});

// 3rd layer of the tree
var tree3 = new Zdog.Cone({
  addTo: treeAnchor,
  diameter: 100,
  length: 50,
  stroke: false,
  color: green3,
  backface: green5,
  rotate: { z: TAU/4.5 },
});

// 4th layer of the tree
var tree4 = new Zdog.Cone({
  addTo: treeAnchor,
  diameter: 120,
  length: 50,
  stroke: false,
  translate: { z: -25 },
  color: green4,
  backface: green5,
  rotate: { z: -TAU/6 },
});

// 5th layer of the tree
var tree5 = new Zdog.Cone({
  addTo: treeAnchor,
  diameter: 140,
  length: 50,
  stroke: false,
  translate: { z: -50 },
  color: green5,
  backface: green5,
  rotate: { z: TAU/10 },
});

// Trunk
new Zdog.Cylinder({
  addTo: treeAnchor,
  diameter: 30,
  length: 80,
  stroke: false,
  translate: { z: -60 },
  color: trunk,
  backface: trunkBottom,
});

// ----------------------------------------------- //

// Shadow
new Zdog.Cylinder({
  addTo: treeAnchor,
  diameter: 160,
  length: 1,
  stroke: false,
  translate: { z: -100 },
  color: '#F0EBEB',
});

// ----------------------------------------------- //

var baubleAnchor = new Zdog.Anchor({
  addTo: tree,
});

var baubleZ = ( tree.diameter + tree.stroke ) / 2 - 2;

new Zdog.Shape({
  addTo: baubleAnchor,
  translate: { z: baubleZ },
  stroke: 10,
  color: '#d6336c',
});

baubleAnchor.copyGraph({
  rotate: { x: .9 },
});

baubleAnchor.copyGraph({
  rotate: { x: -.9 },
});

baubleAnchor.copyGraph({
  rotate: { y: .9 },
});

baubleAnchor.copyGraph({
  rotate: { y: -.9 },
});

// ----------------------------------------------- //

var baubleAnchor2 = new Zdog.Anchor({
  addTo: tree2,
});

var baubleGroup2 = new Zdog.Group({
  addTo: baubleAnchor2,
});

var baubleZ2 = ( tree2.diameter + tree2.stroke ) / 2 - 6;

new Zdog.Shape({
  addTo: baubleGroup2,
  translate: { z: baubleZ2 },
  stroke: 10,
  color: '#ffe066',
});

baubleAnchor2.copyGraph({
  rotate: { x: 1.2 },
});

baubleAnchor2.copyGraph({
  rotate: { x: -1.2 },
});

baubleAnchor2.copyGraph({
  rotate: { y: 1.2 },
});

baubleAnchor2.copyGraph({
  rotate: { y: -1.2 },
});

// ----------------------------------------------- //

var baubleAnchor3 = new Zdog.Anchor({
  addTo: tree3,
});

var baubleZ3 = ( tree3.diameter + tree3.stroke ) / 2 - 8;

new Zdog.Shape({
  addTo: baubleAnchor3,
  translate: { z: baubleZ3 },
  stroke: 10,
  color: '#74c0fc',
});

baubleAnchor3.copyGraph({
  rotate: { x: 1.3 },
});

baubleAnchor3.copyGraph({
  rotate: { x: -1.3 },
});

baubleAnchor3.copyGraph({
  rotate: { y: 1.3 },
});

baubleAnchor3.copyGraph({
  rotate: { y: -1.3 },
});

// ----------------------------------------------- //

var baubleAnchor4 = new Zdog.Anchor({
  addTo: tree4,
});

var baubleZ4 = ( tree4.diameter + tree4.stroke ) / 2 - 10;

new Zdog.Shape({
  addTo: baubleAnchor4,
  translate: { z: baubleZ4 },
  stroke: 10,
  color: '#c0eb75',
});

baubleAnchor4.copyGraph({
  rotate: { x: 1.3 },
});

baubleAnchor4.copyGraph({
  rotate: { x: -1.3 },
});

baubleAnchor4.copyGraph({
  rotate: { y: 1.3 },
});

baubleAnchor4.copyGraph({
  rotate: { y: -1.3 },
});

// ----------------------------------------------- //

var baubleAnchor5 = new Zdog.Anchor({
  addTo: tree5,
});

var baubleZ5 = ( tree5.diameter + tree5.stroke ) / 2 - 10;

new Zdog.Shape({
  addTo: baubleAnchor5,
  translate: { z: baubleZ5 },
  stroke: 12,
  color: '#e599f7',
});

baubleAnchor5.copyGraph({
  rotate: { x: 1.4 },
});

baubleAnchor5.copyGraph({
  rotate: { x: -1.4 },
});

baubleAnchor5.copyGraph({
  rotate: { y: 1.4 },
});

baubleAnchor5.copyGraph({
  rotate: { y: -1.4 },
});

// ----------------------------------------------- //

// Star
new Zdog.Polygon({
  addTo: illo,
  radius: 13,
  sides: 5,
  stroke: 2,
  translate: { z: -0, y: -80 },
  color: '#EA0',
  fill: true,
});


function animate() {
  illo.rotate.y += 0.01;
  illo.updateRenderGraph();
  requestAnimationFrame( animate );
}
animate();

class Snowing {

  constructor(el) {

    var total = 500;
    this.holder = document.querySelector('.snow');
    this.winW = window.innerWidth;
    this.winH = window.innerHeight;

    for (let i = 0; i < total; i++){

      var particle = document.createElement('div');
      TweenLite.set(particle, {attr:{class:'snow__particle'}, x:this.random(0, this.winW), y:this.random(-200,-150), z:this.random(-200,200)});
      this.holder.appendChild(particle);

      this.animm(particle);
    }

  }

  animm(elm) {
    TweenMax.to(elm, this.random(3,6.5), {y:this.winH + 100, ease:Linear.easeNone, repeat:-1, delay:-15});
    TweenMax.to(elm, this.random(5,7), {x:'+=100', repeat:-1, yoyo:true, ease:Sine.easeInOut});
  }

  random(min,max) {
    return min+Math.random()*(max-min)
  }

}

var snowing = new Snowing;

              
            
!
999px

Console