Javascript, css, html all in one file in notepad, javascript not working - TechRepublic
Question
June 15, 2021 at 02:59 PM
spencer1621515293

Javascript, css, html all in one file in notepad, javascript not working

by spencer1621515293 . Updated 5 years, 1 month ago

Hi, I have put javascript, html and css all on one page in notepad++. But the picture, which is a clock will display, but will not do anything, so I think the javascript is not working. Can anyone tell me where I have gone wrong here please and if all the code on one file is allowed. here is the full page code:

clock!

html {
background: linear-gradient(to right, rgba(90, 93, 145, 1) 0%, rgba(173, 255, 99, 1) 100%);
text-align: center;
font-size: 10px;
}

body {
margin: 0;
font-size: 2rem;
display: flex;
flex: 1;
min-height: 100vh;
align-items: center;
}

.clock {
width: 30rem;
height: 30rem;
border: 20px solid white;
margin: 50px auto;
border-radius: 100%;
position: relative;
padding: 2rem;
box-shadow:
0 0 0 4px rgba(0, 0, 0, 0.1),
inset 0 0 0 3px #EFEFEF,
inset 0 0 10px black,
0 0 10px rgba(0, 0, 0, 0.2);
}

.clock-face {
position: relative;
width: 100%;
height: 100%;
transform: translateY(-3px);
}

.hand {
width: 50%;
height: 6px;
background: black;
position: absolute;
top: 50%;
transform-origin: 100%;
transform: rotate(90deg);
transition: 0.3s all;
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);

}

const hourHand = document.querySelector(‘.hand-hour’);
const minuteHand = document.querySelector(‘.hand-minute’);
const secondHand = document.querySelector(‘.hand-seconds’);

function getTime() {
const now = new Date();

const seconds = now.getSeconds();
const secondsDegree = (((seconds / 60) * 360) + 90);
secondHand.style.transform = `rotate(${secondsDegree}deg)`

const minutes = now.getMinutes();
const minutesDegree = (((minutes / 60) * 360) + 90);
minuteHand.style.transform = `rotate(${minutesDegree}deg)`

const hours = now.getHours();
const hoursDegree = (((hours / 60) * 360) + 90);
hourHand.style.transform = `rotate(${hoursDegree}deg)`

}

setInterval(getTime, 1000);

<

div class=

"

hand hand-hou

This discussion is locked

All Comments