css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              /**
 * Variables
 */
$color__light_blue: #CAE4F2;
$color__dark_blue: #2A6FB0; /* 42, 111, 176 */
$color__dark_blue_alpha: rgba(42,111,176,0.3);
$color__dark_blue_dark_alpha: rgba(42,111,176,0.8);
$color__light_green: #65C0A5;
$color__dark_green: #0B8972; /* #35a66f
*/
$color__dark_green_alpha: #6DB8AA;
$color__light_red: #F17259;
$color__light_red_alpha: #F38E7A;
$color__dark_red: #9D1313;

$font_stack__body: 'Nunito', 'Quicksand', 'Valero Round', sans-serif;
$font_stack__headings: 'Sonsie One', cursive;

$section_height: 100vh;
$section_width: calc( 100vw + 17px );
$post_width: 600px;

* {
  position: relative;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-size: 16px;
  background: $color__light_blue;
  font-family: $font_stack__body;
  font-weight: 100;
  letter-spacing: -0.2px;
  line-height: 1.6;
}
h1, h2, h3, h4, h5, h6 {
  font-family: $font_stack__headings;
}

/**
 * Countdown Clock
 */
.countdown-clock {
  width: 560px;
  height: 120px;
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: $color__dark_blue;
  opacity: 0.3;
  border-top: 2px solid $color__dark_blue;
  border-bottom: 2px solid $color__dark_blue;
}
.pie {
  fill: transparent;
  stroke: white;
  stroke-width: 100;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray .3s ease;
}
.pie-plate {
  position: absolute;
  top: -8px;
  left: -20px;
  z-index: -1; 
  background: transparent;
  border-radius: 50%;
  display: block;
  transform: rotate(-90deg);
}

#countdown {
  list-style: none;
  margin-bottom: 1em;
}
#countdown li {
  display: inline-block;
  margin: 1em 2em;
  position: relative;
}
#countdown .number {
  font-size: 3em;
  margin: 10px 0 0;
  padding: 0;
  line-height: 1;
}
#countdown .label {
  margin-top: -5px;
}
            
          
!
            
              /*
 * Let it snow!
 */
$.fn.snow();

/**
 * Countdown Component
 */
var Countdown = React.createClass({
  render: function() {
    return (
      <div className="countdown-clock">
    <ul id="countdown">
      <li id="days">
        <div className="number">00</div>
        <div className="label">Days</div>
        <svg width="100" height="100" className="pie-plate">
          <circle r="50" cx="50" cy="50" className="pie" />
        </svg>
      </li>
      <li id="hours">
        <div className="number">00</div>
        <div className="label">Hours</div>
        <svg width="100" height="100" className="pie-plate">
          <circle r="50" cx="50" cy="50" className="pie" />
        </svg>
      </li>
      <li id="minutes">
        <div className="number">00</div>
        <div className="label">Minutes</div>
        <svg width="100" height="100" className="pie-plate">
          <circle r="50" cx="50" cy="50" className="pie" stroke-dasharray="10"/>
        </svg>
      </li>
      <li id="seconds">
        <div className="number">00</div>
        <div className="label">Seconds</div>
        <svg width="100" height="100" className="pie-plate">
          <circle r="50" cx="50" cy="50" className="pie" />
        </svg>
      </li>
    </ul>
    <p>Remaining 'til Christmas <span className="this-year"></span></p>
  </div>
    )
  }
});
ReactDOM.render(
  <Countdown/>,
  document.querySelector('#clock')
);

/**
 * Date Countdown timer
 * @link https://codepen.io/chrisjdesigner/pen/dMbmoE
 */
var thisYear = new Date();
var thisChristmas = thisYear.getFullYear() + "/12/25 00:00:00";
var christmas = new Date( thisChristmas ),
    days, hours, mins, secs;

/* Display the current Year in the subheading */
$('.this-year').text( thisYear.getFullYear() );

$(function() {
  // Calculate time to Christmas
  timeToXmas();
  // Transition from 0
  numberTrans( '#days .number', days, 1000, 'easeOutQuad' );
  numberTrans( '#hours .number', hours, 1000, 'easeOutQuad' );
  numberTrans( '#minutes .number', mins, 1000, 'easeOutQuad' );
  numberTrans( '#seconds .number', secs, 1000, 'easeOutQuad' );
  // Begin countdown
  setTimeout( countdownTimer, 1001 );
});

// function to calc Time to Christmas
function timeToXmas() {
  var today = new Date(); 
  // diff between dates
  var diff = (today - christmas)/1000;
  var diff = Math.abs(Math.floor(diff));
  
  // Day to target
  days = Math.floor(diff/(24*60*60));
  secs = diff - days * 24*60*60;
  // Hours
  hours = Math.floor(secs/(60*60));
  secs = secs - hours * 60*60;
  // Minutes
  mins = Math.floor(secs/60);
  secs = secs - mins * 60;
}

// function to display the countdown Timer
function countdownTimer() {
  timeToXmas();
  // display in front-end clock
  // Seems like multiplying by 360(degrees) gives an inaccurate measure - 315 is the proper number to be an even division of the pie graph clock
  $( '#days .number' ).text(days);
  var dayResult = 315*(days/25) + ' ' + 360;
  $( '#days .pie' ).css( { "stroke-dasharray": dayResult } );
  $( '#hours .number' ).text(hours);
  var hrResult = 315*(hours/24) + ' ' + 360;
  $( '#hours .pie' ).css( { "stroke-dasharray": hrResult } );
  $( '#minutes .number' ).text(mins);
  var minResult = 315*(mins/60) + ' ' + 360;
  $( '#minutes .pie' ).css( { "stroke-dasharray": minResult } );
  $( '#seconds .number' ).text(secs);
  var secResult = 315*(secs/60) + ' ' + 360;
  $( '#seconds .pie' ).css( { "stroke-dasharray": secResult } );
  // repeat every second
  setTimeout(countdownTimer, 1000);
}

// Transition numbers
function numberTrans( id, endpt, transDur, transEase ) {
  $({numberCount: $(id).text()}).animate({numberCount: endpt}, {
    duration: transDur,
    easing: transEase,
    step: function() {
      $(id).text(Math.floor(this.numberCount));
    },
    complete: function() {
      $(id).text(this.numberCount);
    }
  });
};
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console