Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a webpage that displays a clock where the second, minute, and hour hands tick. Write CSS to have the clock face, second, minute, hour

Create a webpage that displays a clock where the second, minute, and hour hands tick.

Write CSS to have the clock face, second, minute, hour hands all display correctly on top of each other. Make sure the red second hand displays on top of the minute and hour hand. (Try changing the order the div elements are written in the HTML)

Create intervals in the JavaScript file to make the clocks tick.

Use CSS transform rotation to rotate the hands of the clock.

.rotate { transform: rotate(45deg) }

Change CSS values in JavaScript by getting reference to them through the DOM and setting a new value to their CSS properties:

let degrees = 45; const el = document.getElementById("myElement") el.style.transform = "rotate(" + degrees + "deg)"

It would be useful to define functions that convert seconds, minutes and hours to how many degrees the hand should be rotated around the clock!

secondRotation(0) // returns 0 secondRotation(59) // returns (59 / 60) * 360 hourRotation(12) // returns 0 hourRotation(5) // returns (5 / 12) * 360

Bonus: Show Actual Time

Use JavaScripts Date objects to display the actual time.

const now = new Date()

Get now by declaring a new Date object. You can google for "MDN date methods" to see what helpful methods are attached to Date objects. There's helpful things like .getMonth(), .getSeconds() and who knows what else!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

2. Discuss the steps in preparing a manager to go overseas.

Answered: 1 week ago

Question

8. Measure the effectiveness of the succession planning process.

Answered: 1 week ago