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

              
                <html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Christmas Countdown</title>
</head>
<body>
<div id="rightcolumn">
    <div id='timer' class='test'></div>
</div>
    
 </body>
 </html>
              
            
!

CSS

              
                html{
    background-color: black;
    background: url(http://www.nicholasmaassel.com/images/Christmas_Final.png) no-repeat center center fixed;
    background-size: cover;

    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
}

img.bg{
    width: 100%;
    height: auto;
    overflow: auto;
}

#rightcolumn{
    
}

#timer{
    background-color: rgba( 256, 256, 256, 0.9);
    color: red;
    font-family: futura, verdana, sans-serif;
    font-size: 2.0em;
    margin: 10px 200px 0 20px;
    padding: 1em;
    

   -moz-box-shadow:    inset 0 0 10px #000000;
   -webkit-box-shadow: inset 0 0 10px #000000;
   box-shadow:         inset 0 0 10px #000000;
}
              
            
!

JS

              
                /* Timer Variables */
var Timer;

var dString = "December, 25, 2013";
var targetDate = new Date(dString);

window.onload = function() {
  CreateTimer("timer");
}

function CreateTimer(TimerID) {
    Timer = document.getElementById(TimerID);

    UpdateTimer();
    window.setTimeout("Tick()", 1000);
}

function Tick() {
    UpdateTimer();
    window.setTimeout("Tick()", 1000);
}

function UpdateTimer() {
    var date = new Date();
    
    var Months = getMonthsLeft(date);
    var Days = getDaysLeft(date);
    var Hours = getHoursLeft(date);
    var Minutes = getMinutesLeft(date);
    var Seconds = getSecondsLeft(date);
  
  // Returns one of two expressions depending on a condition
  // test ? expression1 : expression2 
    var TimeStr = Months + Days + LeadingZero(Hours) + ":" + LeadingZero(Minutes) + ":" + LeadingZero(Seconds);

    Timer.innerHTML = TimeStr + " until Christmas!";
}

function LeadingZero(Time) {
    return (Time < 10) ? "0" + Time : +Time;
}

function getMonthsLeft(date) {
  // Get the current month from 0 to 11
  // ex. November is 10 (not 11)
  // Add 1 to make the month # correct
  // ex. November will actually be 11 now
    var currentMonth = date.getMonth() + 1;
    var monthsLeft = 12 - currentMonth;
    return ((monthsLeft > 0) ? monthsLeft + " month" : "");
}
function getDaysLeft(date) {
  var daysLeft = ", ";
  var Month = date.getMonth();
  
  // If we just want the days left in the current month ((Month!=12) or (Month=12 && getDate() > 25))
  if ((Month!=12) || (Month==12 && getDate() > 25)) {
    // http://stackoverflow.com/a/1184359/2895248
    var daysinMonth = new Date(date.getYear(), date.getMonth(), 0).getDate();
    daysLeft += daysinMonth - date.getDate();
    return daysLeft + " days, ";
  }
  
  // If it's December and not yet Christmas
  // subtract the current day from 25
  return daysLeft += date.getDate() - 25 + " days, ";
}
function getHoursLeft(date) {
    var currentHour = date.getHours();
    return 24 - currentHour;
}
function getMinutesLeft(date) {
    var currentMinutes = date.getMinutes();
    return 60 - currentMinutes;
}
function getSecondsLeft(date) {
    var currentSeconds = date.getSeconds();
    return 60 - currentSeconds;
}
              
            
!
999px

Console