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 id="time">Color Clock</h1>
<h1 id="hex" class="hidden">Hex Code</h1>
            
          
!
            
              body {
  background: #CCC9CC;
}

h1 {
  width: auto;
  color: #FFF;
  font-size: 100px;
  margin: 0px;
  font-family: Elegant, Helvetica, Arial;
  position: absolute;
  left: 50%;
  top: 50%;
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  -o-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  text-transform: uppercase;
  cursor: pointer;
}

.hidden {
  display: none;
}
            
          
!
            
              function colorClock() {
  // get time
  var newDate = new Date();
  var hours = newDate.getHours().toString();
  var minutes = newDate.getMinutes().toString();
  var seconds = newDate.getSeconds().toString();

  // format time to HHMMSS
  if (hours < 10) {
    hours = "0" + hours
  };
  if (minutes < 10) {
    minutes = "0" + minutes
  };
  if (seconds < 10) {
    seconds = "0" + seconds
  };
  var time = hours + ":" + minutes + ":" + seconds;

  // create dark (1-1) # color code
  var darkColors = hours + minutes + seconds;

  // replace dark # numbers with lighter characters
  var lightColors = darkColors.replace(/0/g, 'a');
  lightColors = lightColors.replace(/1/g, 'b');
  lightColors = lightColors.replace(/2/g, 'c');

  // update the time on the page
  $("#time").html(time);
  $("#hex").html('#' + lightColors);

  // fade the background color
  Velocity($("body"), {
    backgroundColor: '#' + lightColors
  }, 1000);
}

setInterval(function() {
  colorClock();
}, 1000);

// toggle between time and hex
$('#time, #hex').click(function() {
  $('#time').toggle();
  $('#hex').toggle();
});

colorClock();
            
          
!
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