Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .main
  .clock
    .container.hours-container
      -(1..12).each do |i|
        .axes.axes-hours
          .dot.hours-dot
    .container.minutes-container
      .axes.axes-minutes
        .dot.minutes-dot
    .container.seconds-container
      .axes.axes-seconds
        .dot.seconds-dot
    .container.second-track
      -(1..60).each do |i|
        .axes.axes-second
          .dot

              
            
!

CSS

              
                @import compass

body
  background: #000000
.main
  margin: 100px auto
  width: 200px
  height: 200px
  .clock
    width: 200px
    height: 200px
    position: absolute
    .container
      border: 1px solid transparent
      position: absolute
      display: inline-block
      .axes
        position: absolute
        width: 3px
        .dot
          +border-radius(100%)
          width: 5px
          height: 5px
          background: red
        .hours-dot
          background: transparent
          border: 1px solid red
          +opacity(.3)
        &:nth-child(1) .hours-dot
          width: 8px
          height: 8px
          margin: -1.5px 0 0 -1.5px
          +opacity(1)
    .hours-container
      margin: 60px 60px
      width: 80px
      height: 80px
      +animation(seconds 216000s linear 3600s infinite)
      .axes-hours
        margin-left: 38px
        height: 80px
        @for $i from 0 to 12
          &:nth-child(#{$i + 1})
            +transform(rotate(#{$i * 30}deg))
    .minutes-container
      margin: 40px 40px
      width: 120px
      height: 120px
      .axes-minutes
        margin-left: 58px
        height: 120px
        @for $i from 0 to 1
          &:nth-child(#{$i + 1})
            +animation(seconds 3600s linear #{($i) * 60}s infinite)
    .seconds-container
      margin: 20px 20px
      width: 160px
      height: 160px
      .axes-seconds
        margin-left: 78px
        height: 160px
        @for $i from 0 to 1
          &:nth-child(#{$i + 1})
            +animation(seconds 60s linear #{($i) * 1}s infinite)
    .second-track
      margin: 0 0
      width: 200px
      height: 200px
      .axes-second
        margin-left: 98px
        height: 200px
        @for $i from 0 to 60
          &:nth-child(#{$i + 1})
            +transform(rotate(6deg * $i))
          &:nth-child(#{$i + 1}) .dot
            +border-radius(0)
            width: 10px
            height: 2px
            +opacity(0)
            +animation(track 1s linear #{($i) * .016}s infinite)
+keyframes(seconds)
  0%
    +transform(rotate(0deg))
  100%
    +transform(rotate(360deg))
+keyframes(track)
  0%
    +opacity(1)
    background: green
  100%
    +opacity(0)
              
            
!

JS

              
                /*
Work in progress...
ToDo:
1. Set the time on start - Done
2. Ticks for minutes hand / another animation for minutes hand
3. Color combinations
4. Resize the clock
5. Optimize the code and set default options
6. Set right the hours hand
*/
(function() {
  var _date = new Date(),
    changeRotation = function(element, degrees) {
      var transformType = "transform";
      if(element.style.webkitTransform != undefined) {
        transformType = "webkitTransform";
      } else if(element.style.mozTransform != undefined) {
        transformType = "mozTransform";
      } else if(element.style.msTransform != undefined) {
        transformType = "msTransform";
      }
      element.style[transformType] = "rotate(" + degrees + "deg)";
    },
    hoursContainer = document.querySelector(".hours-container"),
    minutesContainer = document.querySelector(".minutes-container"),
    secondsContainer = document.querySelector(".seconds-container");

	changeRotation(hoursContainer, _date.getHours() % 12 * 30);
  changeRotation(minutesContainer, _date.getMinutes() * 6);
  changeRotation(secondsContainer, _date.getSeconds() * 6);

  var remainingMinutes = 59 - _date.getMinutes(),
  	remainingSeconds = 59 - _date.getSeconds(),
  	totalRemainingSeconds = (remainingMinutes * 60) + remainingSeconds,
    resetMilliseconds = totalRemainingSeconds * 1000;
  
  setTimeout(function() {
    var _date = new Date();
    changeRotation(hoursContainer, _date.getHours() % 12 * 30);
  }, resetMilliseconds);
  console.log("resetMilliseconds >>> " + resetMilliseconds);

  /*
  setTimeout(function() {
    debugger;
    _date = new Date();
    changeRotation(hoursContainer, _date.getHours() % 12 * 30);
  }, ((60 - _date.getMinutes()) * 60 * 1000));
  
  setTimeout(function() {
    alert();
    _date = new Date();
    changeRotation(hoursContainer, _date.getHours() % 12 * 30);
  }, ((60 - _date.getSeconds()) * 1000));
  */
}());

              
            
!
999px

Console