-
Notifications
You must be signed in to change notification settings - Fork 202
/
index.html
80 lines (71 loc) · 2.18 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>恋爱计时器</title>
<style>
body {
-webkit-font-smoothing: antialiased;
font-family: Helvetica Neue, Helvetica, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
background-image: url('bg.jpg');
font-size: 85%;
margin: 0;
}
h2 {
font-size: 220%;
font-weight: 400;
}
.content {
position: absolute;
width: 100%;
top: 40%;
transform: translate(0, -50%);
text-align: center;
}
.timer {
font-size: 180%;
line-height: 1.5;
margin: 1em 0;
}
.timer b {
color: rgb(253, 99, 125);
}
</style>
</head>
<body>
<div class="content">
<h2>呆呆,我们已经在一起了</h2>
<div class="timer">
<b id="d"></b> Days <b id="h"></b> Hours <b id="m"></b> Minutes <b id="s"></b> Seconds
</div>
</div>
<script>
function timer() {
var start = new Date(2013, 12, 1); // 2015.7.2
var t = new Date() - start;
var h = ~~(t / 1000 / 60 / 60 % 24);
if (h < 10) {
h = "0" + h;
}
var m = ~~(t / 1000 / 60 % 60);
if (m < 10) {
m = "0" + m;
}
var s = ~~(t / 1000 % 60);
if (s < 10) {
s = "0" + s;
}
document.getElementById('d').innerHTML = ~~(t / 1000 / 60 / 60 / 24);
document.getElementById('h').innerHTML = h;
document.getElementById('m').innerHTML = m;
document.getElementById('s').innerHTML = s;
}
timer();
setInterval(timer, 1000);
</script>
</body>
</html>