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 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.

            
              <div class="kz-photo">
  <ul class="countdown">
      <li>
        <span class="days"></span>
      </li>
      <li>:</li>
      <li>
        <span class="hours"></span>
      </li>
      <li>:</li>
      <li>
        <span class="minutes"></span>
      </li>
      <li>:</li>
      <li>
        <span class="seconds"></span>
      </li>
    
	</ul>
  
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="260px" height="260px">
<circle class="line ext" cx="130" cy="130" r="117"/>
	<circle class="line days-c" cx="130" cy="130" r="107"/>
<circle class="line hours-c" cx="130" cy="130" r="97"/>
<circle class="line minutes-c" cx="130" cy="130" r="87"/>
<circle class="line secondes-c" cx="130" cy="130" r="77"/>
<circle class="line in" cx="130" cy="130" r="68"/>
</svg>

</div>
            
          
!
            
              body {
  background: black;
}
.kz-photo{
  position: absolute;
          top:50%;
          margin-left: -130px;
          margin-top: -130px;
          left:50%;
}

svg {
  width: 260px;
  height: 260px;
  position: absolute;
  transform:rotate(-90deg);
}

ul {
  color:white;
  position:absolute;
  list-style:none;
  z-index:99;
  width: 260px;
  height: auto;
  font-family:roboto, "sans serif";
  font-size:14px;
  font-weight:lighter;
  letter-spacing:1px;
  color:white;
  text-align:center;
  line-height:260px;
  
  li {
    display:inline-block;
    span {
    }
  }
}

.line {
  fill: none;
  stroke: #808080;
  stroke-width: 1px;
}

.ext {
  stroke:white;
  stroke-width:1px;
  stroke-dasharray: 1,60.2;
}

.in {
  stroke:rgba(255,255,255,0.5);
  stroke-width:1px;
  stroke-dasharray: 1,70.1;
}

.days-c {
  stroke-dasharray: 672;
  transform:rotate(-270deg);
}

.hours-c {
  stroke-dasharray: 609;
  transform:rotate(-180deg);
}

.minutes-c {
  stroke-dasharray: 547;
  transform:rotate(-90deg);
}

.secondes-c {
  stroke:#d03b3f;
  stroke-dashoffset:0;
  stroke-dasharray: 484;
  transform:rotate(-360deg);
}

circle {
  transform-origin:center;
  transition:transform 1.5s ease;}

.kz-photo:hover circle {
  transform:rotate(0deg);
}

            
          
!
            
              //Countdown plugin

(function($) {
    $.fn.countdown = function(options, callback) {

      //custom 'this' selector
      var thisEl = $(this);

      //array of custom settings
      var settings = { 
        'date': null,
        'format': null
      };

      //append the settings array to options
      if(options) {
        $.extend(settings, options);
      }

      //main countdown function
      var countdown_proc = function () {

        var eventDate = Date.parse(settings['date']) / 1000;
        var currentDate = ($.now() / 1000);

        if(eventDate <= currentDate) {
          callback.call(this);
          clearInterval(interval);
        };

        var seconds = eventDate - currentDate;
        
        var days = Math.floor(seconds / (60 * 60 * 24)); //calculate the number of days
        seconds -= days * 60 * 60 * 24; //update the seconds variable with no. of days removed
        
        var hours = Math.floor(seconds / (60 * 60));
        seconds -= hours * 60 * 60; //update the seconds variable with no. of hours removed

        var minutes = Math.floor(seconds / 60);
        seconds -= minutes * 60; //update the seconds variable with no. of minutes removed
        
        
        var offsetdays = ((672 * (24 - hours) * 60 * 60) / 86400);
        var offsethours = ((609 * (60 - minutes) * 60) / 3600);
        var offsetminutes = ((547 * (60 - seconds)) / 60);
        var offsetsecondes = (484 * (60 - seconds));
        
        var seconds = Math.floor(seconds);
        
        //logic for the two_digits ON setting
        if(settings['format'] == "on") {
          days = (String(days).length >= 2) ? days : "0" + days;
          hours = (String(hours).length >= 2) ? hours : "0" + hours;
          minutes = (String(minutes).length >= 2) ? minutes : "0" + minutes;
          seconds = (String(seconds).length >= 2) ? seconds : "0" + seconds;
        }

        //update the countdown's html values.
        if(!isNaN(eventDate)) {
          thisEl.find(".days").text(days);
          thisEl.find(".hours").text(hours);
          thisEl.find(".minutes").text(minutes);
          thisEl.find(".seconds").text(seconds);
        } else { 
          alert("Invalid date. Here's an example: 12 Tuesday 2012 17:30:00");
          clearInterval(interval); 
        }
         //defini le debut du cercle
      $('.days-c').css({
        'stroke-dashoffset' : offsetdays
      });
      $('.hours-c').css({
        'stroke-dashoffset' : offsethours
      });
      $('.minutes-c').css({
        'stroke-dashoffset' : offsetminutes
      });
      $('.secondes-c').css({
        'stroke-dashoffset' : offsetsecondes
      });
      }
      
      //run the function
      countdown_proc();
      

      //loop the function
      interval = setInterval(countdown_proc, 10);

    }
}) (jQuery);


//Call countdown plugin
$(".countdown").countdown({
  date: "1 january 2019 0:00:00", // add the countdown's end date (i.e. 3 november 2012 12:00:00)
  format: "on" // on (03:07:52) | off (3:7:52) - two_digits set to ON maintains layout consistency
},

function() {

  // the code here will run when the countdown ends
  alert("done!")

});
            
          
!
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