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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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 id="snowglobe-container">
  <div id="snowglobe">
      <div class="counter">
        <p class="days"><span id="number"></span> Days </p>
        <p>Until Christmas</p>
    </div>
    <canvas id='snow'></canvas>
  </div>
</div>
              
            
!

CSS

              
                $blue: #1f303b;
$red: #b03d38;
$green: #6bb792;
$font-stack: 'Libre Franklin',
sans-serif;
body {
  background: #f0f0ee;
}

#snowglobe-container {
  width: 100%;
  max-width: 400px;
  margin: 125px auto;
}

#snowglobe {
  position: relative;
  
}

.counter {
  position: absolute;
  font-family: $font-stack;
  width: 100%;
  padding: 50% 0;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
  color: #fff;
}

.counter p {
  margin: 0;
  font-weight: 500;
  font-size: 1.25em;
  color: $green;
  margin-left:50px;
}

.counter p.days {
  font-size: 2rem;
  font-weight: 700;
  color: #f0f0ee;
}

canvas#snow {
  width: 100%;
  height: 100%;
  background: $blue;
  border-radius: 100%;
}
              
            
!

JS

              
                //Snow effect
//https://codepen.io/otsukatomoya/pen/gbDxF/

var w = 300, //window.innerWidth,
  h = 300, // window.innerHeight,
  canvas = document.getElementById('snow'),
  ctx = canvas.getContext('2d'),
  rate = 50,
  arc = 100,
  time,
  count,
  size = 2,
  speed = 2,
  lights = new Array,
  colors = ['#7d8896', '#456274', '#859cab'];

canvas.setAttribute('width', w);
canvas.setAttribute('height', h);

function init() {
  time = 0;
  count = 0;

  for (var i = 0; i < arc; i++) {
    lights[i] = {
      x: Math.ceil(Math.random() * w),
      y: Math.ceil(Math.random() * h),
      toX: Math.random() * 5 + 1,
      toY: Math.random() * 5 + 1,
      c: colors[Math.floor(Math.random() * colors.length)],
      size: Math.random() * size
    }
  }
}

function bubble() {
  ctx.clearRect(0, 0, w, h);

  for (var i = 0; i < arc; i++) {
    var li = lights[i];

    ctx.beginPath();
    ctx.arc(li.x, li.y, li.size, 0, Math.PI * 2, false);
    ctx.fillStyle = li.c;
    ctx.fill();

    li.x = li.x + li.toX * (time * 0.05);
    li.y = li.y + li.toY * (time * 0.05);

    if (li.x > w) {
      li.x = 0;
    }
    if (li.y > h) {
      li.y = 0;
    }
    if (li.x < 0) {
      li.x = w;
    }
    if (li.y < 0) {
      li.y = h;
    }
  }
  if (time < speed) {
    time++;
  }
  timerID = setTimeout(bubble, 1000 / rate);
}
init();
bubble();

//Christmas Countdown
var daysTilXmas = function() {
  var today = new Date(); //set variable for today
  var day = 24 * 60 * 60 * 1000; //set variable for day in milliseconds

  //find next christmas
  if ((today.getMonth() === 11) && (today.getDate() > 25)) {
    var nextXmas = Date.parse((today.getFullYear() + 1) + "-12-25");
  } else {
    var nextXmas = Date.parse((today.getFullYear()) + "-12-25");
  };

  //parse today to get millisecond value of today 
  var todayValue = Date.parse(today);

  //If it's not christmas
  if (nextXmas - todayValue > day) {
    var daysLeft = (nextXmas - todayValue) / day;
    document.querySelector('#number').innerHTML = Math.round(daysLeft);

  } else {
    //write code for christmas day text.
  };

}

daysTilXmas();
              
            
!
999px

Console