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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="digit hour1">
  <div class="stick one">
    <div class="stick three">
      <div class="stick seven"></div>
    </div>
  </div>
  <div class="stick two">
    <div class="stick four">
      <div class="stick five"></div>
    </div>
  </div>
  <div class="stick six"></div>
</div>

<div class="digit hour2">
  <div class="stick one">
    <div class="stick three">
      <div class="stick seven"></div>
    </div>
  </div>
  <div class="stick two">
    <div class="stick four">
      <div class="stick five"></div>
    </div>
  </div>
  <div class="stick six"></div>
</div>

<div class="colon">:</div>

<div class="digit min1">
  <div class="stick one">
    <div class="stick three">
      <div class="stick seven"></div>
    </div>
  </div>
  <div class="stick two">
    <div class="stick four">
      <div class="stick five"></div>
    </div>
  </div>
  <div class="stick six"></div>
</div>

<div class="digit min2">
  <div class="stick one">
    <div class="stick three">
      <div class="stick seven"></div>
    </div>
  </div>
  <div class="stick two">
    <div class="stick four">
      <div class="stick five"></div>
    </div>
  </div>
  <div class="stick six"></div>
</div>

<div class="sec">
  <div class="digit sec1">
    <div class="stick one">
      <div class="stick three">
        <div class="stick seven"></div>
      </div>
    </div>
    <div class="stick two">
      <div class="stick four">
        <div class="stick five"></div>
      </div>
    </div>
    <div class="stick six"></div>
  </div>

  <div class="digit sec2">
    <div class="stick one">
      <div class="stick three">
        <div class="stick seven"></div>
      </div>
    </div>
    <div class="stick two">
      <div class="stick four">
        <div class="stick five"></div>
      </div>
    </div>
    <div class="stick six"></div>
  </div>
</div>
              
            
!

CSS

              
                html {
  height: 100%;
}

body {
  --width: 2vmin;
  --len: 8vmin;
  --color: #4b80ff;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background: #000;
}

.colon {
  position: relative;
  margin: calc(var(--width) + 1vmin);
}

.colon::before,
.colon::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: var(--width);
  height: var(--width);
  background: var(--color);
}

.colon::before {
  top: calc(0vmin - var(--len) / 2);
}

.colon::after {
  bottom: calc(0vmin - var(--len) / 2);
}

.digit {
  position: relative;
  width: var(--len);
  margin: calc(var(--width) + 1vmin);
}

.sec {
  display: flex;
  margin: var(--len) calc(0vmin - var(--len) * 2) 0 var(--width);
  transform: scale(0.5);
  transform-origin: 0 100%;
}

.stick {
  --half-width: calc(var(--width) / 2);
  --origin-left: calc(0vmin - var(--half-width));
  --origin-right: calc(var(--len) + var(--half-width));
  position: absolute;
  width: var(--len);
  height: var(--width);
  background: var(--color);
  border-radius: 11% / 15%;
  transition: transform 0.4s;
}

.stick::before,
.stick::after {
  content: '';
  position: absolute;
  top: 0;
  border: var(--half-width) solid transparent;
}

.stick::before {
  right: 98%;
  border-right: var(--half-width) solid var(--color);
}

.stick::after {
  left: 98%;
  border-left: var(--half-width) solid var(--color);
}

.stick.one {
  transform-origin: var(--origin-right) 50%;
  transform: rotate(90deg);
}

.stick.two {
  transform-origin: var(--origin-right) 50%;
  transform: rotate(270deg);
}

.stick.three {
  transform-origin: var(--origin-left) 50%;
  transform: rotate(90deg);
}

.stick.four {
  transform-origin: var(--origin-left) 50%;
  transform: rotate(270deg);
}

.stick.five {
  transform-origin: var(--origin-right) 50%;
  transform: rotate(270deg);
}

.stick.six {
  transform-origin: var(--origin-right) 50%;
  transform: rotate(0deg);
}

.stick.seven {
  transform-origin: var(--origin-right) 50%;
  transform: rotate(90deg);
}

              
            
!

JS

              
                const sticksByDigits = Array.from(document.querySelectorAll('.digit'))
  .map($d => ['one', 'two', 'three', 'four', 'five', 'six', 'seven']
    .map(i => $d.querySelector(`.stick.${i}`))
  )

const digitMap = [
  [ 90, 270,  90, 270, 270, 90,  90 ],
  [ 90, -90,   0, 360, 360, 90,   0 ],
  [ 90,   0,  90, 450,  90, 90,   0 ],
  [ 90, 270,  90, 270, 360,  0,   0 ],
  [  0, 270, 270, 360, 360, 90,   0 ],
  [  0, 270, 270, 270, 360,  0, 270 ],
  [  0, 270, -90, 270, 270,  0, -90 ],
  [ 90, 270,  90, 360, 360, 90,   0 ],
  [ 90, 270,  90, 270, 270,  0,  90 ],
  [ 90, 270,  90, 360, 360,  0,  90 ],
]

updateTime
setInterval(updateTime, 1000)

function updateTime () {
  const d = new Date()
  const hour = String(d.getHours()).padStart(2, '0')
  const min = String(d.getMinutes()).padStart(2, '0')
  const sec = String(d.getSeconds()).padStart(2, '0')
  setDigit(hour + min + sec)
}

function setDigit (digits) {
  sticksByDigits.forEach(($sticks, iDigit) => {
    const digit = digits[iDigit]
    $sticks.forEach(($stick, iStick) => {
      $stick.style.transform = `rotate(${digitMap[digit][iStick]}deg)`
    })
  })
}

              
            
!
999px

Console