cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <h1>Christmas Countdown</h1>

<div id="clockdiv">
  <div class="inner">
    <span class="days"></span>
    <div class="smalltext">Days</div>
  </div>
  <div class="inner">
    <span class="hours"></span>
    <div class="smalltext">Hours</div>
  </div>
  <div class="inner">
    <span class="minutes"></span>
    <div class="smalltext">Minutes</div>
  </div>
  <div class="inner">
    <span class="seconds"></span>
    <div class="smalltext">Seconds</div>
  </div>
</div>
            
          
!
            
              /* http://material.colorion.co/palette/3320 */
body {
  font-family: 'Righteous', cursive;
  color:white;
  text-align: center;
  background: #dd4848;
  background-image: url('https://i.imgur.com/BiSmXaq.png'), url('https://i.imgur.com/XHuy0NJ.png'), url('https://i.imgur.com/okpRxJU.png');
  -webkit-animation: snow 20s linear infinite;
  -moz-animation: snow 20s linear infinite;
  -ms-animation: snow 20s linear infinite;
  animation: snow 20s linear infinite;
}

@-webkit-keyframes snow {
  0% { background-position: 0px, 0px, 0px, 0xp, 0xp, 0xp}
  50% { background-color: #dc5959 }
  100% { background-position: 500px 1000px, 400px 400px, 300px 300px;
  background-color: #dd4848;
  }
}
@-moz-keyframes snow {
  0% { background-position: 0px, 0px, 0px, 0xp, 0xp, 0xp}
  50% { background-color: #dc5959 }
  100% { background-position: 500px 1000px, 400px 400px, 300px 300px;
  background-color: #dd4848;
  }
}
@-ms-keyframes snow {
  0% { background-position: 0px, 0px, 0px, 0xp, 0xp, 0xp}
  50% { background-color: #dc5959 }
  100% { background-position: 500px 1000px, 400px 400px, 300px 300px;
  background-color: #dd4848;
  }
}
@keyframes snow {
  0% { background-position: 0px, 0px, 0px, 0xp, 0xp, 0xp}
  50% { background-color: #dc5959 }
  100% { background-position: 500px 1000px, 400px 400px, 300px 300px;
  background-color: #dd4848;
  }
}

h1 {
  text-align:center;
  font-size: 60px;
  color:white;
  text-shadow: 4px 2px 3px rgba(0,0,0, 0.6);
  margin-bottom: 10px;
  margin-top: 100px;
}

#clockdiv {
  width: 1000px;
  width: 100%;
  top:50%;
  left:50%;
  font-size: 50px;
}
.inner {
  display:inline-block;
  border: 5px solid white;
  padding: 20px;
  width: 80px;
  height: 80px;
  box-shadow: 5px 5px 5px rgba(0,0,0, 0.5);
  background: repeating-linear-gradient(55deg, 
    rgba(221, 72, 72, 0.1), 
    rgba(221, 72, 72, 0.1) 5px,
    rgba(255, 255, 255, 0.2) 5px, 
    rgba(255, 255, 255, 0.2) 10px);
}
.inner .smalltext {
  font-size: 20px;
  text-shadow: 4px 2px 3px rgba(0,0,0, 0.6);
}

.days {
  text-shadow: 4px 2px 3px rgba(0,0,0, 0.6);
}
.hours {
  text-shadow: 4px 2px 3px rgba(0,0,0, 0.6);
}
.minutes {
  text-shadow: 4px 2px 3px rgba(0,0,0, 0.6);
}
.seconds {
  text-shadow: 4px 2px 3px rgba(0,0,0, 0.6);
}

            
          
!
            
              /* https://www.sitepoint.com/build-javascript-countdown-timer-no-dependencies/ */

function getTimeRemaining(endtime){
  var t = Date.parse(endtime) - Date.parse(new Date());
  var seconds = Math.floor( (t/1000) % 60);
  var minutes = Math.floor( (t/1000 / 60) % 60);
  var hours = Math.floor( (t/(1000 * 60 * 60)) % 24);
  var days = Math.floor( t/(1000 * 60 * 60 * 24));
  return {
    'total': t,
    'days': days,
    'hours': hours,
    'minutes': minutes,
    'seconds': seconds
  };
}

function initializeClock(id, endtime){
  var clock = document.getElementById(id);
  var daysSpan = clock.querySelector('.days');
  var hoursSpan = clock.querySelector('.hours');
  var minutesSpan = clock.querySelector('.minutes');
  var secondsSpan = clock.querySelector('.seconds');
  
  function updateClock(){
    var t = getTimeRemaining(endtime);
    
    daysSpan.innerHTML = t.days;
    hoursSpan.innerHTML = ('0' + t.hours).slice(-2);
    minutesSpan.innerHTML = ('0' + t.minutes).slice(-2);
    secondsSpan.innerHTML = ('0' + t.seconds).slice(-2);
    
    if(t.total <= 0){
      clearInterval(timeinterval);
    }
  }
  
  updateClock();
  var timeinterval = setInterval(updateClock,1000);
}

var deadline = '2017-12-24';
initializeClock('clockdiv', deadline);
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console