-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
107 lines (94 loc) · 2.93 KB
/
index.html
File metadata and controls
107 lines (94 loc) · 2.93 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Controle de tempo</title>
<style>
* {
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
}
body {
background: linear-gradient(135deg, #1d2b64, #f8cdda);
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff;
padding: 20px;
}
h2 {
font-size: 4rem;
margin-bottom: 30px;
text-shadow: 2px 2px 4px #00000066;
}
#timer {
font-size: 3rem;
margin-top: 20px;
text-shadow: 2px 2px 4px #00000066;
}
button {
padding: 12px 24px;
margin-top: 30px;
font-size: 1.1rem;
border: none;
border-radius: 8px;
cursor: pointer;
background-color: #ffffff33;
color: white;
backdrop-filter: blur(4px);
transition: background-color 0.3s;
}
button:hover {
background-color: #ffffff55;
}
hr {
width: 80%;
margin: 40px 0;
border: 1px solid #ffffff44;
}
</style>
</head>
<body>
<h2 id="relogio"></h2>
<hr>
<div id="timer">0:0:0</div>
<button onclick="iniciar()">Iniciar Timer</button>
<script>
function atualizarRelogio(){
const agora = new Date();
const horas = agora.getHours().toString().padStart(2, '0');
const minut = agora.getMinutes().toString().padStart(2, '0');
const segun = agora.getSeconds().toString().padStart(2, '0');
document.getElementById("relogio").innerText = `${horas}:${minut}:${segun}`;
}
setInterval(atualizarRelogio, 1000);
atualizarRelogio();
</script>
<script>
let segundos = 0;
let intervalo;
function formatar(segundos){
const h = String(Math.floor(segundos / 3600)).padStart(2, '0');
const m = String(Math.floor((segundos % 3600) / 60)).padStart(2, '0');
const s = String(segundos % 60).padStart(2, '0');
return `${h}:${m}:${s}`;
}
function atualizarTimer(){
document.getElementById("timer").innerText = formatar(segundos);
}
function iniciar(){
if(!intervalo){
intervalo = setInterval(() => {
segundos++;
atualizarTimer();
}, 1000);
}
}
</script>
</body>
</html>