CSS Variable-Powered Clock
How do I make an css variable-powered clock?
Design based off: https://dribbble.com/shots/2271565-Day-095-Time-is-Money. What is a css variable-powered clock? How do you make a css variable-powered clock? This script and codes were developed by Emily Hayman on 14 June 2022, Tuesday.
CSS Variable-Powered Clock - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS Variable-Powered Clock</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Montserrat:400,700'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="clock-container"> <div class="clock-col"> <p class="clock-day clock-timer"> </p> <p class="clock-label"> Day </p> </div> <div class="clock-col"> <p class="clock-hours clock-timer"> </p> <p class="clock-label"> Hours </p> </div> <div class="clock-col"> <p class="clock-minutes clock-timer"> </p> <p class="clock-label"> Minutes </p> </div> <div class="clock-col"> <p class="clock-seconds clock-timer"> </p> <p class="clock-label"> Seconds </p> </div>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.2/moment.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
CSS Variable-Powered Clock - Script Codes CSS Codes
.clock-day:before { content: var(--timer-day);
}
.clock-hours:before { content: var(--timer-hours);
}
.clock-minutes:before { content: var(--timer-minutes);
}
.clock-seconds:before { content: var(--timer-seconds);
}
body { background: -webkit-linear-gradient(45deg, #1870ed 0, #f18f88 100%); background: linear-gradient(45deg, #1870ed 0, #f18f88 100%); font-family: 'Montserrat', 'sans-serif'; min-height: 100vh; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
}
.clock-container { margin-top: 30px; margin-bottom: 30px; background-color: #080808; border-radius: 5px; padding: 60px 20px; box-shadow: 1px 1px 5px rgba(255, 255, 255, 0.15), 0 15px 90px 30px rgba(0, 0, 0, 0.25); display: -webkit-box; display: -ms-flexbox; display: flex;
}
.clock-col { text-align: center; margin-right: 40px; margin-left: 40px; min-width: 90px; position: relative;
}
.clock-col:not(:last-child):before, .clock-col:not(:last-child):after { content: ""; background-color: rgba(255, 255, 255, 0.3); height: 5px; width: 5px; border-radius: 50%; display: block; position: absolute; right: -42px;
}
.clock-col:not(:last-child):before { top: 35%;
}
.clock-col:not(:last-child):after { top: 50%;
}
.clock-timer:before { color: #fff; font-size: 4.2rem; text-transform: uppercase;
}
.clock-label { color: rgba(255, 255, 255, 0.35); text-transform: uppercase; font-size: .7rem; margin-top: 10px;
}
@media (max-width: 825px) { .clock-container { -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; padding-top: 40px; padding-bottom: 40px; } .clock-col + .clock-col { margin-top: 20px; } .clock-col:before, .clock-col:after { display: none !important; }
}
CSS Variable-Powered Clock - Script Codes JS Codes
document.addEventListener('DOMContentLoaded', () => requestAnimationFrame(updateTime)
)
function updateTime() { document.documentElement.style.setProperty('--timer-day', "'" + moment().format("dd") + "'"); document.documentElement.style.setProperty('--timer-hours', "'" + moment().format("k") + "'"); document.documentElement.style.setProperty('--timer-minutes', "'" + moment().format("mm") + "'"); document.documentElement.style.setProperty('--timer-seconds', "'" + moment().format("ss") + "'"); requestAnimationFrame(updateTime);
}
Developer | Emily Hayman |
Username | eehayman |
Uploaded | June 14, 2022 |
Rating | 4.5 |
Size | 3,362 Kb |
Views | 218,592 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
The Rhetoric of Donald Trump - A Data Visualization | 10,050 Kb |
Full Page Parallax Scroll Effect | 4,446 Kb |
SVG Stroke Animation - Origami Crane | 12,007 Kb |
Custom Dropdown List | 4,266 Kb |
Slider Animation Effect | 8,794 Kb |
Single Div Apple Mouse | 2,987 Kb |
A Pen by Emily Hayman | 1,569 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
CSS Hover Effects | Alen | 3,613 Kb |
Animated skewed panes | NyX | 4,462 Kb |
Drag and Drop Quiz | Cgspicer | 3,837 Kb |
CSS Chat Bubbles | Boylett | 2,094 Kb |
A Pen by Alex Edwards | Exards | 8,218 Kb |
A simple log in form made with css | Mayurelbhar | 2,160 Kb |
Lightrays v2 | Sinthetyc | 2,903 Kb |
Responsive scrolling text | Ashdurham | 2,259 Kb |
IbrahimJabbari-Effect21 | Ibrahimjabbari | 1,882 Kb |
Barber Shop | Bhlaird | 6,270 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!