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.

            
              <div class="main-wrapper">
  <div class="content">
    <div class="blockHolder hourTen"></div>
    <div class="blockHolder hourUnit"></div>
    <div class="blockSeparator"></div>
    <div class="blockHolder minTen"></div>
    <div class="blockHolder minUnit"></div>
    <div class="blockSeparator"></div>
    <div class="blockHolder secTen"></div>
    <div class="blockHolder secUnit"></div>
  </div>
</div>
            
          
!
            
              html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: #111111;
}

.main-wrapper {
  height: 100%;
  width: 100%;
  position: relative;
}

.content {
  position: relative;
  top: 50%;
  left: 50%;
  -webkit-transform: translateY(-50%) translateX(-50%);
      -ms-transform: translateY(-50%) translateX(-50%);
          transform: translateY(-50%) translateX(-50%);
  margin: 0 auto;
  overflow: hidden;
  display: inline-block;
}

.blockHolder {
  display: inline-block;
  width: 180px;
  height: 288px;
  margin:0 15px;
}

.blockSeparator {
  display: inline-block;
  width: 25px;
  height: 288px;
}

.block-wrapper {
  position: relative;
  height:30px;
  width: 30px;
  float: left;
  margin: 3px;
  z-index: 1;
}

.block-inner {
  width: 100%;
  height: 100%;
  -webkit-transform-style: preserve-3d;
          transform-style: preserve-3d;
  -webkit-transition: all 1.0s linear;
          transition: all 1.0s linear;
}

.block-wrapper.active .block-inner {
  -webkit-transform: rotateY(180deg);
          transform: rotateY(180deg);
}

.block {
  background: #333;
  position: absolute;
  width: 30px;
  height: 30px;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
}

.block.back {
  display: block;
  -webkit-transform: rotateY(180deg);
          transform: rotateY(180deg);
  box-sizing:border-box;
  background: #FFF;
}

            
          
!
            
              /* 
Each LCD display is a 5x8 grid. Starting in the top-left and working across, each square has a number from 0 to 35 (later turned into a class "number0", "number1", etc). The numberGroup array holds which squares in the grid should be "active" in order to display the number. I worked this out by coloring a piece of paper.
*/
var numberGroup = {};
numberGroup[0] = [1,2,3,5,9,10,14,15,19,20,24,25,29,30,34,36,37,38];
numberGroup[1] = [2,6,7,12,17,22,27,32,36,37,38];
numberGroup[2] = [1,2,3,5,9,14,18,22,26,30,35,36,37,38,39];
numberGroup[3] = [1,2,3,5,9,14,17,18,24,29,30,34,36,37,38];
numberGroup[4] = [3,7,8,11,13,15,18,20,21,22,23,24,28,33,38];
numberGroup[5] = [0,1,2,3,4,5,10,15,16,17,18,24,29,30,34,36,37,38];
numberGroup[6] = [2,3,6,10,15,16,17,18,20,24,25,29,30,34,36,37,38];
numberGroup[7] = [0,1,2,3,4,9,13,18,22,27,31,36];
numberGroup[8] = [1,2,3,5,9,10,14,16,17,18,20,24,25,29,30,34,36,37,38];
numberGroup[9] = [1,2,3,5,9,10,14,15,19,21,22,23,24,29,33,36,37];

/*
The buildBlock function is called when the six grids are being made. It loops through each individual pixel and determines which numbers in the display switch this pixel on. It then creates a string of classes for each pixel.

For example, the classes string for the top-left (0) pixel are "number5 number7".
*/
function buildBlock(x) {
  var blockClass = '';
  for (y = 0; y < 10; y++) {
    /*
    look to see which of the numberGroup arrays this pixel is located in.
    If found, add it to the class list (prefixing each number with "number")
    */
     if (numberGroup[y].indexOf(x) > -1) {
       blockClass = blockClass + 'number' + y + ' ';
     }
  }
  //spit out the result
  return blockClass
}

/*
displayNumber is called to switch the pixels around for each second.
  className: Which grid we're referring to (e.g. hourTen, hourUnit, minTen etc.)
  number: The number that grid needs to display
*/
function displayNumber(className, number) {
  var className = '.' + className;
  var number = '.number' + number;
  var selector = className + ' ' + number;
  //remove "active" class from all pixels
  $(className + ' .block-wrapper').removeClass("active");
  //add "active" class to the pixels that will display the correct number.
  $(selector).addClass("active");
}

/*
timeFunc is the ticking clock. Every second it uses moment.js to get the current time, which is split up into each individual number. Each number is then sent to displayNumber() to activate the relevant pixels for the grid.
*/
function timeFunc() {
  setInterval(function() {
    var now = moment();
    var hours = moment(now).format('HH').split('');
    var minutes = moment(now).format('mm').split('');
    var seconds = moment(now).format('ss').split('');
    displayNumber('hourTen', hours[0]);
    displayNumber('hourUnit', hours[1]);
    displayNumber('minTen', minutes[0]);
    displayNumber('minUnit', minutes[1]);
    displayNumber('secTen', seconds[0]);
    displayNumber('secUnit', seconds[1]);
  }, 1000);
}

/*
The start of everything. This function inserts the pixels into the grids, with classes that refer to the number that pixel helps to display (see: buildBlock()).

Once built, it starts the clock with timeFunc().
*/

$(document).ready(function () {
  for (i = 0; i < 40; i++) {
    var classBlock = buildBlock(i);
    $('.blockHolder').append('<div class="' + classBlock + 'block-wrapper"><div class="block-inner"><div class="block"></div><div class="block back"></div></div></div>');
  }
  timeFunc();
});

            
          
!
999px
Loading ..................

Console