JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
<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>
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);
}
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)`
})
})
}
Also see: Tab Triggers