SOURCE

console 命令行工具 X clear

                    
>
console
<div class="home-welcome">
  <div class="container">
    <div class="main-example">
      <p>
        距离明年开始还有:
      </p>
      <div class="countdown-container" id="main-example"></div> 
    </div>
    <script type="text/template" id="main-example-template">
      <div class="time <%= label %>">
        <span class="count curr top"><%= curr %></span>
        <span class="count next top"><%= next %></span>
        <span class="count next bottom"><%= next %></span>
        <span class="count curr bottom"><%= curr %></span>
        <span class="label"><%= label.length < 6 ? label : label.substr(0, 3)  %></span>
      </div>
    </script>
    <script type="text/javascript">
      $(window).on('load', function() {
        var labels = ['周', '天', '时', '分', '秒'],
          nextYear = (new Date().getFullYear() + 1) + '/01/01',
          template = _.template($('#main-example-template').html()),
          currDate = '00:00:00:00:00',
          nextDate = '00:00:00:00:00',
          parser = /([0-9]{2})/gi,
          $example = $('#main-example');
        // Parse countdown string to an object
        function strfobj(str) {
          var parsed = str.match(parser),
            obj = {};
          labels.forEach(function(label, i) {
            obj[label] = parsed[i]
          });
          return obj;
        }
        // Return the time components that diffs
        function diff(obj1, obj2) {
          var diff = [];
          labels.forEach(function(key) {
            if(obj1[key] !== obj2[key]) {
              diff.push(key);
            }
          });
          return diff;
        }
        // Build the layout
        var initData = strfobj(currDate);
        labels.forEach(function(label, i) {
          $example.append(template({
            curr: initData[label],
            next: initData[label],
            label: label
          }));
        });
        // Starts the countdown
        $example.countdown(nextYear, function(event) {
          var newDate = event.strftime('%w:%d:%H:%M:%S'),
            data;
          if(newDate !== nextDate) {
            currDate = nextDate;
            nextDate = newDate;
            // Setup the data
            data = {
              'curr': strfobj(currDate),
              'next': strfobj(nextDate)
            };
            // Apply the new values to each node that changed
            diff(data.curr, data.next).forEach(function(label) {
              var selector = '.%s'.replace(/%s/, label),
                $node = $example.find(selector);
              // Update the node
              $node.removeClass('flip');
              $node.find('.curr').text(data.curr[label]);
              $node.find('.next').text(data.next[label]);
              // Wait for a repaint to then flip
              _.delay(function($node) {
                $node.addClass('flip');
              }, 50, $node);
            });
          }
        });
      });
    </script>
  </div>
</div>
*{
  margin:0;
  padding:0;
}
.home-welcome {
    background-image: linear-gradient(45deg, #361752, #B31B67);
    background-image: -webkit-linear-gradient(45deg, #361752, #B31B67);
    background-image: -moz-linear-gradient(45deg, #361752, #B31B67);
    background-image: -ms-linear-gradient(45deg, #361752, #B31B67);
    background-image: -o-linear-gradient(45deg, #361752, #B31B67);
    color: white;
    padding: 2em 0 2em;
    font-size: 125%;
}
.container {
    max-width: 1170px;
    margin: 0 auto;
    padding: 1em 2em;
}
.main-example {
  margin: 0 auto;
  width: 355px;
}
.main-example .countdown-container {
  height: 130px;
}
.main-example .time {
  border-radius: 5px;
  box-shadow: 0 0 10px 0 rgba(0,0,0,0.5);
  display: inline-block;
  text-align: center;
  position: relative;
  height: 95px;
  width: 65px;

  -webkit-perspective: 479px;
  -moz-perspective: 479px;
  -ms-perspective: 479px;
  -o-perspective: 479px;
  perspective: 479px;

  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  -o-backface-visibility: hidden;
  backface-visibility: hidden;

  -webkit-transform: translateZ(0);
  -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  -o-transform: translateZ(0);
  transform: translateZ(0);

  -webkit-transform: translate3d(0,0,0);
  -moz-transform: translate3d(0,0,0);
  -ms-transform: translate3d(0,0,0);
  -o-transform: translate3d(0,0,0);
  transform: translate3d(0,0,0);
}
.main-example .count {
  background: #202020;
  color: #f8f8f8;
  display: block;
  font-family: 'Oswald', sans-serif;
  font-size: 2em;
  line-height: 2.4em;
  overflow: hidden;
  position: absolute;
  text-align: center;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  top: 0;
  width: 100%;

  -webkit-transform: translateZ(0);
  -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  -o-transform: translateZ(0);
  transform: translateZ(0);

  -webkit-transform-style: flat;
  -moz-transform-style: flat;
  -ms-transform-style: flat;
  -o-transform-style: flat;
  transform-style: flat;
}
.main-example .count.top {
  border-top: 1px solid rgba(255,255,255,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px 5px 0 0;
  height: 50%;

  -webkit-transform-origin: 50% 100%;
  -moz-transform-origin: 50% 100%;
  -ms-transform-origin: 50% 100%;
  -o-transform-origin: 50% 100%;
  transform-origin: 50% 100%;
}
.main-example .count.bottom {
  background-image: linear-gradient(rgba(255,255,255,0.1), transparent);
  background-image: -webkit-linear-gradient(rgba(255,255,255,0.1), transparent);
  background-image: -moz-linear-gradient(rgba(255,255,255,0.1), transparent);
  background-image: -ms-linear-gradient(rgba(255,255,255,0.1), transparent);
  background-image: -o-linear-gradient(rgba(255,255,255,0.1), transparent);
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  border-radius: 0 0 5px 5px;
  line-height: 0;
  height: 50%;
  top: 50%;

  -webkit-transform-origin: 50% 0;
  -moz-transform-origin: 50% 0;
  -ms-transform-origin: 50% 0;
  -o-transform-origin: 50% 0;
  transform-origin: 50% 0;
}
.main-example .count.next {
}
.main-example .label {
  font-size: normal;
  margin-top: 5px;
  display: block;
  position: absolute;
  top: 95px;
  width: 100%;
}
/* Animation start */
.main-example .count.curr.top {
  -webkit-transform: rotateX(0deg);
  -moz-transform: rotateX(0deg);
  -ms-transform: rotateX(0deg);
  -o-transform: rotateX(0deg);
  transform: rotateX(0deg);
  z-index: 3;
}
.main-example .count.next.bottom {
  -webkit-transform: rotateX(90deg);
  -moz-transform: rotateX(90deg);
  -ms-transform: rotateX(90deg);
  -o-transform: rotateX(90deg);
  transform: rotateX(90deg);
  z-index: 2;
}
/* Animation end */
.main-example .flip .count.curr.top {
  -webkit-transition: all 250ms ease-in-out;
  -moz-transition: all 250ms ease-in-out;
  -ms-transition: all 250ms ease-in-out;
  -o-transition: all 250ms ease-in-out;
  transition: all 250ms ease-in-out;

  -webkit-transform: rotateX(-90deg);
  -moz-transform: rotateX(-90deg);
  -ms-transform: rotateX(-90deg);
  -o-transform: rotateX(-90deg);
  transform: rotateX(-90deg);
}
.main-example .flip .count.next.bottom {
  -webkit-transition: all 250ms ease-in-out 250ms;
  -moz-transition: all 250ms ease-in-out 250ms;
  -ms-transition: all 250ms ease-in-out 250ms;
  -o-transition: all 250ms ease-in-out 250ms;
  transition: all 250ms ease-in-out 250ms;

  -webkit-transform: rotateX(0deg);
  -moz-transform: rotateX(0deg);
  -ms-transform: rotateX(0deg);
  -o-transform: rotateX(0deg);
  transform: rotateX(0deg);
}
@media screen and (max-width: 48em) {
  .main-example .countdown-container {
    height: 100px;
  }
  .main-example .time {
      height: 70px;
      width: 48px;
  }
  .main-example .count {
    font-size: 1.5em;
    line-height: 70px;
  }
  .main-example .label {
    font-size: 0.8em;
    top: 72px;
  }
}

本项目引用的自定义外部资源