Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <style>
- /*# JSAnalogClock.html */
- body {
- background-color: #272727;
- margin: 0;
- }
- body div {
- width: 100%;
- height: 100%;
- }
- body div ul {
- position: absolute;
- top: 50%;
- left: 50%;
- -webkit-transform: translate(-50%, -50%);
- transform: translate(-50%, -50%);
- width: 301px;
- height: 301px;
- padding: 0px;
- border-radius: 50%;
- list-style: none;
- -webkit-box-shadow: 0 0 20px 5px aqua;
- box-shadow: 0 0 20px 5px aqua;
- }
- body div ul li {
- position: absolute;
- font-size: 25px;
- -webkit-transform-origin: left;
- transform-origin: left;
- color: white;
- }
- body div ul li:nth-child(1) {
- width: 155px;
- height: 15px;
- top: 147px;
- left: 148px;
- text-align: center;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(-60deg);
- transform: rotate(-60deg);
- }
- body div ul li:nth-child(2) {
- width: 155px;
- height: 15px;
- top: 145px;
- left: 145px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: center;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(-30deg);
- transform: rotate(-30deg);
- }
- body div ul li:nth-child(3) {
- width: 155px;
- height: 15px;
- top: 140px;
- left: 145px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- }
- body div ul li:nth-child(4) {
- width: 155px;
- height: 15px;
- top: 140px;
- left: 146px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(30deg);
- transform: rotate(30deg);
- }
- body div ul li:nth-child(5) {
- width: 155px;
- height: 15px;
- top: 138px;
- left: 148px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(60deg);
- transform: rotate(60deg);
- }
- body div ul li:nth-child(6) {
- width: 155px;
- height: 15px;
- top: 138px;
- left: 152px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(90deg);
- transform: rotate(90deg);
- }
- body div ul li:nth-child(7) {
- width: 155px;
- height: 15px;
- top: 137px;
- left: 151px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(120deg);
- transform: rotate(120deg);
- }
- body div ul li:nth-child(8) {
- width: 155px;
- height: 15px;
- top: 139px;
- left: 154px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(150deg);
- transform: rotate(150deg);
- }
- body div ul li:nth-child(9) {
- width: 155px;
- height: 15px;
- top: 142px;
- left: 154px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(180deg);
- transform: rotate(180deg);
- }
- body div ul li:nth-child(10) {
- width: 155px;
- height: 26px;
- top: 140px;
- left: 154px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(210deg);
- transform: rotate(210deg);
- }
- body div ul li:nth-child(11) {
- width: 155px;
- height: 26px;
- top: 142px;
- left: 152px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(240deg);
- transform: rotate(240deg);
- }
- body div ul li:nth-child(12) {
- width: 155px;
- height: 26px;
- top: 142px;
- left: 150px;
- -webkit-transform-origin: left;
- transform-origin: left;
- text-align: right;
- -webkit-writing-mode: vertical-rl;
- -ms-writing-mode: tb-rl;
- writing-mode: vertical-rl;
- -webkit-transform: rotate(270deg);
- transform: rotate(270deg);
- }
- body div ul li:nth-child(13) {
- width: 0px;
- height: 0px;
- top: 145px;
- left: 150px;
- -webkit-transform-origin: left;
- transform-origin: left;
- -webkit-transform: rotate(-90deg);
- transform: rotate(-90deg);
- border-top: 5px solid transparent;
- border-left: 120px solid aqua;
- border-bottom: 5px solid transparent;
- }
- body div ul li:nth-child(14) {
- width: 0;
- height: 0;
- top: 146px;
- left: 150px;
- -webkit-transform-origin: left;
- transform-origin: left;
- -webkit-transform: rotate(-90deg);
- transform: rotate(-90deg);
- border-top: 5px solid transparent;
- border-left: 150px solid aqua;
- border-bottom: 5px solid transparent;
- }
- body div ul li:nth-child(15) {
- width: 0px;
- height: 0px;
- top: 147px;
- left: 113.5px;
- -webkit-transform-origin: 20%;
- transform-origin: 20%;
- -webkit-transform: rotate(-90deg);
- transform: rotate(-90deg);
- border-top: 3px solid transparent;
- border-left: 185px solid aqua;
- border-bottom: 3px solid transparent;
- }
- body div ul li:nth-child(16) {
- width: 18px;
- height: 18px;
- top: 141px;
- left: 141px;
- border-radius: 50%;
- background-color: black;
- -webkit-box-shadow: inset 0 0 0px 4px #00a4e6;
- box-shadow: inset 0 0 0px 4px #00a4e6;
- }
- /*# sourceMappingURL=main.css.map */
- </style>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Analog Clock | JS and SCSS</title>
- <link rel="stylesheet" href="main.css">
- </head>
- <body style="margin-bottom: 0px !important;">
- <div>
- <ul>
- <li>1</li>
- <li>2</li>
- <li>3</li>
- <li>4</li>
- <li>5</li>
- <li>6</li>
- <li>7</li>
- <li>8</li>
- <li>9</li>
- <li>10</li>
- <li>11</li>
- <li>12</li>
- <li style="transform: rotate(-60deg);"></li>
- <li style="transform: rotate(72deg);"></li>
- <li style="transform: rotate(204deg);"></li>
- <li></li>
- </ul>
- </div>
- <script>
- function c(data) {
- console.log(data);
- }
- // get clock from the machine
- const askDate = new Date();
- // clock pointers degrees caclulator
- let hoursStep = -90 + (askDate.getHours() * 30);
- let minutesStep = -90 + (askDate.getMinutes() * 6);
- let secondsStep = -90 + (askDate.getSeconds() * 6);
- // DOM current time setup
- const elements = document.body.childNodes;
- elements[1].childNodes[1].childNodes[25].style.transform = "rotate(" + hoursStep + "deg)";
- elements[1].childNodes[1].childNodes[27].style.transform = "rotate(" + minutesStep + "deg)";
- elements[1].childNodes[1].childNodes[29].style.transform = "rotate(" + secondsStep + "deg)";
- // seconds pointer engine
- setInterval(() => {
- elements[1].childNodes[1].childNodes[29].style.transform = "rotate(" + secondsStep + "deg)";
- secondsStep = secondsStep + 6;
- if (secondsStep == 276) {
- secondsStep = -84;
- minutesStep = minutesStep + 6;
- elements[1].childNodes[1].childNodes[27].style.transform = "rotate(" + minutesStep + "deg)";
- check();
- }
- }, 1000);
- // prevent infinite degrees for hours and minutes
- function check() {
- if (minutesStep == 270) {
- minutesStep = -84;
- hoursStep = hoursStep + 30;
- elements[1].childNodes[1].childNodes[25].style.transform = "rotate(" + hoursStep + "deg)";
- }
- if (hoursStep == 270 || hoursStep == 630) {
- hoursStep = -90;
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement