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.

Quick-add: + add another resource

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.

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

Console