<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Javascript Clock UI Dark</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div class="clock">
        <div class="hour">
            <div class="hr" id="hr"></div>
        </div>
        <div class="min">
            <div class="mn" id="mn"></div>
        </div>
        <div class="sec">
            <div class="sc" id="sc"></div>
        </div>
    </div>
    <script type="text/javascript">
        const deg = 6;
        const hr = document.querySelector('#hr');
        const mn = document.querySelector('#mn');
        const sc = document.querySelector('#sc');
        setInterval(()=>{
             // 현재 시간 구하기.
            // https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
            let day = new Date();
            //시침들의 회전값이므로 값을 곱해준다.
            let hh = day.getHours() * 30;
            let mm = day.getMinutes() * deg;
            let ss = day.getSeconds() * deg;
            hr.style.transform = `rotateZ(${hh + (mm / 12)}deg)`;
            mn.style.transform = `rotateZ(${mm}deg)`;
            sc.style.transform = `rotateZ(${ss}deg)`;
        })
    </script>
</body>

</html>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #292837;
}

.clock {
    width: 350px;
    height: 350px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #091921 url(clock.png);
    background-size: cover;
    border-radius: 50%;
    border: 4px solid #091921;
    /* inset 사용으로 상하 좌우 그림자 설정. 
    https://css-tricks.com/almanac/properties/i/inset/  */
    box-shadow: 0 -15px 15px rgba(255, 255, 255, 0.05),
        0 20px 20px rgba(0, 0, 0, 0.3),
        inset 0 -15px 15px rgba(255, 255, 255, 0.05),
        inset 0 20px 20px rgba(0, 0, 0, 0.3);
}

.clock::before
/* 시계 중심점 생성. */
{
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    background: #fff;
    border-radius: 50%;
    z-index: 10000;
}

.hour, .min, .sec
{
    position: absolute;
}
.hour, .hr
{
    width: 160px;
    height: 160px;
}
.min, .mn 
{
    width: 190px;
    height: 190px;
}
.sec, .sc 
{
    width: 230px;
    height: 230px;
}
.hr, .mn, .sc
{
    display: flex;
    justify-content: center;
    position: absolute;
    border-radius: 50%;
}
.hr::before
{
    content: '';
    position: absolute;
    width: 8px;
    height: 80px;
    background: #ff105e;
    z-index: 10;
    border-radius: 6px 6px 0 0;
}
.mn::before 
{
    content: '';
    position: absolute;
    width: 4px;
    height: 90px;
    background: #ffffff;
    z-index: 11;
    border-radius: 6px 6px 0 0;
}
.sc::before 
{
    content: '';
    position: absolute;
    width: 2px;
    height: 150px;
    background: #363fea;
    z-index: 12;
    border-radius: 6px 6px 0 0;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.