123

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .title
  span Day 6. Clock

.clock
  .clock__bg
  .clock__body
    ul.clock__body__hours.clock__body__lines
      - for (i=0; i<12; i++)
      li
      - end
    ul.clock__body__minutes.clock__body__lines
      - for (i=0; i<60; i++)
      li
      - end
    ul.clock__body__seconds.clock__body__lines
      - for (i=0; i<300; i++)
      li
      - end
    ul.clock__body__hours__ticks.clock__body__lines
      - for (i=0; i<12; i++)
      li
      - end
    .clock__body__decorative
    .clock__title CASIO
    .clock__subtitle WATER RESIST <br><span>50M</span>
    .clock__hour__container
      .clock__hour
    .clock__minute__container
      .clock__minute
    .clock__second__container
      .clock__second
    .clock__dot
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Pacifico');
@import url('https://fonts.googleapis.com/css?family=Titillium+Web:400,700');

$white: hsla(0,0,100%,0.8);

*, 
*::before, 
*::after {
  box-sizing: border-box;
}

*::before, 
*::after {
  content: '';
  display: block;
  position: absolute;
}

body {
  background-color: hsla(202,50%,50%,1);
  background-image: radial-gradient(hsla(202,50%,80%,1) 0%, hsla(202,50%,40%,1) 100%);
  min-height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  font-family: 'Titillium Web', sans-serif;
}

.title {  
  font-family: 'Pacifico', cursive;
  padding: 10px 20px;
  
  span {
    font-size: 20px;
    font-weight: bold;
    color: rgba(0,0,0,0.5);
  }
}

.clock {
  $size: 70vmin;
  width: $size;
  height: $size;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  
  &::before {
    width: 80%;
    height: 100%;
    background-image: linear-gradient(45deg, #bbb 0%,#ddd 100%);
    top: 0;
    left: 10%;
    clip-path: polygon(10% 0%, 90% 0%, 100% 50%, 90% 100%, 10% 100%, 0% 50%);
    z-index: -1;
  }
  &::after {
    $bg-size: ($size/20);
    // http://lea.verou.me/css3patterns/#carbon
    background:
    linear-gradient(27deg, #b5b5b5 $bg-size, transparent $bg-size) 0 $bg-size,
      linear-gradient(207deg, #b5b5b5 $bg-size, transparent $bg-size) #{$bg-size * 2} 0px,
      linear-gradient(27deg, #ccc $bg-size, transparent $bg-size) 0px #{$bg-size * 2},
      linear-gradient(207deg, #ccc $bg-size, transparent $bg-size) #{$bg-size * 2} $bg-size,
      linear-gradient(90deg, #bbbbbb #{$bg-size * 2}, transparent #{$bg-size * 2}),
    linear-gradient(#bdbdbd 25%, #bababa 25%, #bababa 50%, transparent 50%, transparent 75%, #ccc 75%, #ccc);
    background-color: #b3b3b3;
    background-size: #{$size / 8} #{$size / 8};
    width: 60%;
    height: 130%;
    top: -25%;
    left: 20%;
    z-index: -1;
  }
  
  &__title {
    position: absolute;
    color: white;
    font-weight: bold;
    font-size: #{$size / 20};
    top: 25%;
    width: 100%;
    text-align: center;
    transform: scaleY(0.6);
  }
  &__subtitle {
    position: absolute;
    color: white;
    font-size: #{$size / 40};
    bottom: 25%;
    width: 100%;
    text-align: center;
    transform: scaleY(0.8);
    
    span {
      font-size: #{$size / 30};
    }
  }
  
  &__dot {
    $dot-size: 4%;
    width: $dot-size;
    height: $dot-size;
    background-image: linear-gradient(-45deg, #ccc 0%, #ddd 100%);
    box-shadow: 0 0 1px rgba(0,0,0,0.3);
    position: absolute;
    top: 48%;
    left: 48%;
    border-radius: 100%;
    &::before {
      width: 20%;
      height: 20%;
      top: 40%;
      left: 40%;
      border-radius: 100%;
      background: rgba(0,0,0,0.1);
    }
  }
  
  &__hour {
    &__container {
      position: absolute;
      width: 100%;
      height: 100%;
    }
    position: absolute;
    width: 100%;
    height: 100%;
    animation: rotate 43200s infinite linear;
    &::before {
      width: 5%;
      height: 40%;
      top: 20%;
      left: 50%;
      transform: translatex(-50%);
      background: linear-gradient(90deg, #ddd 0%, #bbb 100%);
      border: 1px solid rgba(255,255,255,0.2);
      box-shadow: 0 0 3px rgba(0,0,0,0.5);
      clip-path: polygon(50% 0%, 100% 10%, 80% 95%, 50% 100%, 20% 95%, 0% 10%);
    }
  }
  
  &__minute {
    &__container {
      position: absolute;
      width: 100%;
      height: 100%;
    }
    position: absolute;
    width: 100%;
    height: 100%;
    animation: rotate 3600s infinite linear;
    &::before {
      width: 4%;
      height: 50%;
      top: 10%;
      left: 50%;
      transform: translatex(-50%);
      background: linear-gradient(90deg, #ccc 0%, #aaa 100%);
      border: 1px solid rgba(255,255,255,0.2);
      box-shadow: 0 0 3px rgba(0,0,0,0.5);
      clip-path: polygon(50% 0%, 100% 10%, 90% 95%, 50% 100%, 10% 95%, 0% 10%);
    }
  }
  
  &__second {
    &__container {
      position: absolute;
      width: 100%;
      height: 100%;
    }
    position: absolute;
    width: 100%;
    height: 100%;
    animation: rotate 60s infinite steps(60);
    &::before {
      width: 1%;
      height: 60%;
      top: 5%;
      left: 50%;
      transform: translatex(-50%);
      background: linear-gradient(90deg, #ccc 0%, #aaa 100%);
      border: 1px solid rgba(255,255,255,0.2);
      box-shadow: 0 0 3px rgba(0,0,0,0.5);
      clip-path: polygon(50% 0%, 100% 10%, 90% 95%, 50% 100%, 10% 95%, 0% 10%);
    }
    &::after {
      width: 1%;
      height: 60%;
      top: 5%;
      left: 50%;
      transform: translatex(-50%);
      background: linear-gradient(0deg, transparent 0%, transparent 60%, rgba(200,0,0,0.8) 60%, rgba(200,0,0,0.8) 100%);
      clip-path: polygon(50% 0%, 100% 10%, 90% 95%, 50% 100%, 10% 95%, 0% 10%);
    }
  }
  
  &__bg {
    $bg-size: 80%;
    width: $bg-size;
    height: $bg-size;
    background-color: #aaa;
    background-image: linear-gradient(-45deg, #a2a2a2 0%, #cbcbcb 50%,#c1c1c1 51%,#eeeeee 100%);
    border-radius: 100%;
    position: absolute;
    top: 10%;
    left: 10%;
    
    &::before {
      width: 90%;
      height: 90%;
      background-image: linear-gradient(135deg, rgba(0,0,0,0.3) 0%, rgba(255,255,255,0.7) 100%);
      border-radius: 100%;
      left: 5%;
      top: 5%;
    }
    &::after {
      $line-size: ($size / 100);
      width: 5%;
      height: 10%;
      background-color: #ccc;
      background-image: repeating-linear-gradient(0deg, transparent, transparent $line-size, rgba(0,0,0,.1) $line-size, rgba(0,0,0,.1) #{$line-size * 2});
      right: -4%;
      top: 45%;
      z-index: -1;
    }
  }
  
  &__body {    
    $bg-size: 70%;
    width: $bg-size;
    height: $bg-size;
    background: rgb(28, 59, 108);
    background-image: linear-gradient(45deg, rgb(28, 59, 108) 0%, rgb(48, 79, 128) 100%);
    position: absolute;
    left: 15%;
    top: 15%;
    border-radius: 100%;
    overflow: hidden;
    
    &::after {
      width: 150%;
      height: 150%;
      background: rgba(255,255,255,0.05);
      left: 20%;
      top: -60%;
      border-radius: 100%;
    }
    
    &__decorative {
      $line-size: $size / 200;
      width: 60%;
      height: 60%;
      position: absolute;
      top: 20%;
      left: 20%;
      border-radius: 100%;
      border: 1px solid rgba(0,0,0,0.1);
      background-image: repeating-linear-gradient(45deg, transparent, transparent $line-size, rgba(122,122,122,.1) $line-size, rgba(122,122,122,.1) #{$line-size * 2});
    }
    
    &__lines {
      list-style: none;
      display: block;
      position: absolute;
      width: 100%;
      height: 100%;
      padding: 0;
      margin: 0;
      li {
        display: block;
        position: absolute;
        height: 100%;
        top: 0;
        left: 50%;
        &::before {
          background: $white;
          top: 0;
          width: 100%;
        }
      }
    }
    
    &__hours {      
      li {
        width: 2.5%;        
        &::before {
          height: 4%;
        }
      }
      @for $i from 0 through 12 {
        li:nth-of-type(#{$i}) {
          transform: translateX(-50%) rotate(#{$i * 30}deg);
        }
      }
    }
    
    &__hours__ticks {
      li {
        top: 6%;
        height: 88%;
        width: 3%;
        &::before {
          height: 10%;
          background: linear-gradient(90deg, #ccc 0%, #aaa 100%);
          border: 1px solid rgba(255,255,255,0.2);
          box-shadow: 0 0 2px rgba(0,0,0,0.1);
        }
      }
      li:nth-of-type(12) {
        &::before {
          display: none;
        }
        &::after {
          content: '12';
          display: block;
          letter-spacing: -#{$size / 120};
          font-size: #{$size / 9};
          font-weight: bold;
          transform: translatex(-50%);
          top: -5%;
          text-shadow: 0 0 3px rgba(0, 0, 0, 0.5), 0 0 2px rgba(255, 255, 255, 0.2);
          color: #bbb;
        }
      }
      @for $i from 0 through 11 {
        li:nth-of-type(#{$i}) {
          transform: translateX(-50%) rotate(#{$i * 30}deg);
        }
      }
    }
    
    &__minutes {
      li {
        width: 1%;
        &::before {
          height: 3%;
        }
      }
      @for $i from 0 through 60 {
        li:nth-of-type(#{$i}) {
          transform: translateX(-50%) rotate(#{$i * 6}deg);
        }
      }
      @for $i from 0 through 12 {
        li:nth-of-type(#{$i * 5}) {
          display: none;
        }
      }
    }
    
    &__seconds {
      li {
        width: 0.5%;
        min-width: 1px;
        &::before {
          height: 2%;
        }
      }
      @for $i from 0 through 300 {
        li:nth-of-type(#{$i}) {
          transform: translateX(-50%) rotate(#{$i * 1.2}deg);
        }
      }
      @for $i from 0 through 60 {
        li:nth-of-type(#{$i * 5}),
        li:nth-of-type(#{$i * 25 + 1}),
        li:nth-of-type(#{$i * 25 - 1}) {
          display: none;
        }
      }
    }
  }
}

@keyframes rotate {
  100% {
    transform: rotateZ(360deg);
  }
}
            
          
!
            
              function initLocalClocks() {
  const date = new Date();
  const seconds = date.getSeconds();
  const minutes = date.getMinutes();
  const hours = date.getHours();

  const hands = [
    {
      hand: 'clock__hour__container',
      angle: (hours * 30) + (minutes / 2)
    },
    {
      hand: 'clock__minute__container',
      angle: (minutes * 6) + (seconds / 10)
    },
    {
      hand: 'clock__second__container',
      angle: (seconds * 6)
    }
  ];
  hands.forEach((hand) => {
    const element = document.querySelector('.' + hand.hand);
    element.style.transform = `rotateZ(${ hand.angle }deg)`;
  });
}
initLocalClocks();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console