250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- image
- 비전공자
- 풀스택
- CSS
- css3
- Animation
- react
- 애니메이션
- iPhone
- keyframes
- MAC
- 비전공 개발자
- IOS
- 프론트엔드
- iOS 개발자
- javascript
- php
- 백엔드
- hover
- html5
- effect
- ipad
- 자바스크립트
- SWIFT
- front-end
- button
- HTML
- 개발자
- jQuery
- xcode
Archives
- Today
- Total
비전공자 개발일기
Animated Working Analog Clock 본문
728x90
SMALL
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ANIMATED WORKING ANALOG CLOCK</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<div class="clock">
<div class="numbers">
<span style="--i: 0;"><b>12</b></span>
<span style="--i: 1;"><b>3</b></span>
<span style="--i: 2;"><b>6</b></span>
<span style="--i: 3;"><b>9</b></span>
<div class="circle" id="hr"><i></i></div>
<div class="circle" id="mn"><i></i></div>
<div class="circle" id="sc"><i></i></div>
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
position: relative;
}
body {
display: flex;
justify-content: center;
align-items: center;
background-color: #ACBACA;
min-height: 100vh;
}
.clock {
width: 300px;
height: 300px;
background-color: #C9D5E0;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50px;
box-shadow: 30px 30px 30px -10px rgba(0, 0, 0, .1), inset 15px 15px 10px rgba(255, 255, 255, .75), -15px -15px 35px rgba(255, 255, 255, .55), inset -1px -1px 10px rgba(0, 0, 0, .2);
}
.clock::before {
content: '';
position: absolute;
width: 4px;
height: 4px;
background-color: #E91E63;
border-radius: 50%;
z-index: 1000;
box-shadow: 0 0 0 1px #E91E63, 0 0 0 3px #FFF, 0 0 5px 5px rgba(0, 0, 0, .15);
}
.clock .numbers {
position: absolute;
inset: 35px;
background-color: #152B4A;
border-radius: 50%;
box-shadow: 5px 5px 15px #152B4A66, inset 5px 5px 5px rgba(255, 255, 255, .55), -6px -6px 10px rgba(255, 255, 255, 1);
}
.clock .numbers span {
position: absolute;
inset: 5px;
text-align: center;
color: #FFF;
font-size: 1.25em;
transform: rotate(calc(90deg * var(--i)));
}
.clock .numbers span b {
font-weight: 600;
display: inline-block;
transform: rotate(calc(-90deg * var(--i)));
}
.clock .numbers::before {
content: '';
position: absolute;
inset: 35px;
background: linear-gradient(#2196F3, #E91E63);
border-radius: 50%;
animation: animate 2s linear infinite;
}
@keyframes animate {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(0);
}
}
.clock .numbers::after {
content: '';
position: absolute;
inset: 38px;
background-color: #152B4A;
border-radius: 50%;
}
.clock .numbers .circle {
position: absolute;
inset: 0;
border-radius: 50%;
display: flex;
justify-content: center;
z-index: 10;
}
.clock .numbers .circle i {
position: absolute;
width: 3px;
height: 50%;
background-color: #FFF;
transform-origin: bottom;
}
.clock .numbers .circle#hr i {
width: 4px;
transform: scaleY(.3);
}
.clock .numbers .circle#mn i {
transform: scaleY(.45);
}
.clock .numbers .circle#sc i {
width: 2px;
transform: scaleY(.55);
background-color: #E91E63;
box-shadow: 0 30px 0 #E91E63;
}
let hr = document.querySelector("#hr");
let mn = document.querySelector("#mn");
let sc = document.querySelector("#sc");
setInterval(() => {
let day = new Date();
let hh = day.getHours() * 30;
let mm = day.getMinutes() * 6;
let ss = day.getSeconds() * 6;
hr.style.transform = `rotateZ(${hh + mm / 12}deg)`;
mn.style.transform = `rotateZ(${mm}deg)`;
sc.style.transform = `rotateZ(${ss}deg)`;
});
728x90
LIST
'HTML _CSS' 카테고리의 다른 글
Pendulum Loading (0) | 2023.01.23 |
---|---|
Blob Effect Micro Interaction (0) | 2023.01.22 |
Responsive Tabs (0) | 2023.01.19 |
3D Cube Slider (0) | 2023.01.17 |
Stylish Checkbox (0) | 2023.01.15 |