-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
96 lines (89 loc) · 2.6 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
margin: 0;
}
.main {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background: #70e1f5; /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #ffd194, #70e1f5); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #ffd194, #70e1f5); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 30px;
background: rgba(200, 200, 200, 0.35);
backdrop-filter: blur(40px);
padding: 10px;
border-radius: 12px;
box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px;
margin: 15px;
}
span {
color: black;
font-size: 28px;
text-transform: uppercase;
font-family: monospace;
text-align: center;
padding: 0 10px 0 10px;
}
input {
width: 120px;
height: 35px;
border-radius: 10px;
border-style: solid;
border-color: #515151;
background-color: #909090;
padding: 4px;
font-size: 15px;
text-align: center;
transition: all 0.2s;
}
input:focus {
transform: scale(1.1);
}
</style>
<title>Giorni dal mio compleanno</title>
</head>
<body>
<div class="main">
<div class="box">
<span>Data di nascita: </span>
<input type="date" id="birthday" />
<span>Giorni vissuti: </span>
<span id="daysLived">0</span>
<span>Giorni da raggiungere: </span>
<input type="number" id="daysGoal" />
<span>Data da raggiungere: </span>
<span id="days"></span>
</div>
</div>
<script>
const birthday = document.getElementById("birthday");
const days = document.getElementById("days");
const daysLived = document.getElementById("daysLived");
const daysGoal = document.getElementById("daysGoal");
const updateValues = () => {
daysLived.textContent = birthday.value ? Math.ceil((Date.now() - new Date(birthday.value)) / (1000 * 60 * 60 * 24)) : "0";
const dateGoal = new Date(birthday.value);
dateGoal.setDate(dateGoal.getDate() + parseInt(daysGoal.value));
days.textContent = daysGoal.value ? dateGoal.toLocaleDateString("it-IT") : "";
};
birthday.addEventListener("change", updateValues);
daysGoal.addEventListener("change", updateValues);
</script>
</body>
</html>