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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <html>
<html>
    <head>
        <script type="text/javascript" src="https://code.jquery.com/jquery-1.4.2.js"></script> 
        <title>Happy Holidays!</title>
        <link rel="stylesheet" href="style.css" type="text/css">
    </head>
    <body>
      
   <center> <section>
      <canvas id="canvas"></canvas>
    <!-- Add your heading below this line -->
    <h1>Merry Christmas and Happy New Year</h1>
    
    <!-- I'm a comment! You won't see me on the page! -->
    <h2>Valeh Farzaliyev</h2>
    <img src="https://codecademy-content.s3.amazonaws.com/courses/web-beginner-en-9xjis/images/snowman.png">
        </section>
      </center>
  </body>
</html>
              
            
!

CSS

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

body {
    background: darkslategray;
}
section {
    /* You will add new style rules here */
    margin: auto;
    position: relative;
    background: url(https://codecademy-content.s3.amazonaws.com/courses/web-beginner-en-9xjis/images/winter.jpg);
    width: 700px;
    height: 500px;
    color:  white;
    font-family: Lobster;
    /* I am a comment. */
}
img {
    position: absolute;
    top: 200px;
    left: 120px;
}
h1 {
    /* Any styles here just affect your "<h1>" tags. */
    position: absolute;
    margin: 0;
    top:  0;
    left: 280px;
    font-size: 48px;
}
h2 {
    color: white;
    position: absolute;
    margin: 0;
    top: 360px;
    left: 340px;
    /* Any styles here just affect your "<h1>" tags. */
    font-size: 36px;
}
              
            
!

JS

              
                var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");

var W = 700;
var H = 500;
canvas.width = W;
canvas.height = H;

var numberFlakes = 100;

var flakes = [];
for (var i = 0; i < numberFlakes; i++) {
  flakes.push({
    x: Math.random()*W,
    y: Math.random()*H,
    radius: Math.random()*8+1
  })
}

function drawFlakes() {
  // Have to clear it every time to redraw
  ctx.clearRect(0, 0, W, H);

  ctx.fillStyle = "rgba(255, 255, 255, 0.8)";
  ctx.beginPath();
  for (var i = 0; i < numberFlakes; i++) {
    var f = flakes[i];
    ctx.moveTo(f.x, f.y);
    ctx.arc(f.x, f.y, f.radius, 0, Math.PI*2, true);
  }
  ctx.fill();
  moveFlakes();
}

var angle = 0;

function moveFlakes() {
  
  for (var i = 0; i < numberFlakes; i++) {
    var f = flakes[i];
    
    // cos and sin for moving diagonally
    f.y += Math.cos(angle) + 1 + f.radius/2;
   
    //Start flakes over at top
    if (f.x > W+5 || f.x < -5 || f.y > H) {

      // Introduces some more random behavior to make the snowfall look real
      if (i%3 > 0) {
        flakes[i] = {x: Math.random()*W, y: -10, radius: f.radius};
      } else {
        
        // flake leaves from right
        if (Math.sin(angle) > 0) {
          // come in from left
          flakes[i] = {x: -5, y: Math.random()*H, radius: f.radius};
        } else {
          //come in from right
          flakes[i] = {x: W+5, y: Math.random()*H, radius: f.radius};
        }
      }
    }
  }
}


function init() {
  drawFlakes();
}

setInterval(init, 30);
              
            
!
999px

Console