-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendar.html
80 lines (68 loc) · 2.35 KB
/
calendar.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>
<head>
<style>
:root {
--page-height: 8.5in;
--page-width: 11in;
--header-height: 1.625in;
--border-width: calc(1in / 64);
--row-count: 5;
/* Don't subtract one from row count, because we have the header so there are still 5 lines. */
--row-height: calc((var(--page-height) - var(--header-height) - var(--border-width) * var(--row-count)) / var(--row-count));
--column-count: 7;
--cell-width: calc((var(--page-width) - var(--border-width) * (var(--column-count) - 1)) / var(--column-count));
--border-color: #666666;
}
@page {
size: letter landscape;
margin: 0;
}
body {
margin: 0;
height: var(--page-height);
width: var(--page-width);
}
.row {
display: flex;
border-bottom: var(--border-width) solid var(--border-color);
height: var(--row-height);
}
.row:last-child {
border-bottom: none;
}
.header {
height: var(--header-height);
}
.cell {
border-right: var(--border-width) solid var(--border-color);
width: var(--cell-width);
}
.cell:last-child {
border-right: none;
}
</style>
</head>
<body>
<div class="calendar">
<div class="row header">
<div class="cell"></div>
</div>
</div>
<script>
function parseHTML(html) {
const parser = new DOMParser();
return parser.parseFromString(html, "text/html").body.childNodes[0];
}
const calendar = document.querySelector(".calendar");
for (let i = 0; i < 5; i++) {
const row = parseHTML(`<div class="row"></div>`);
for (let i = 0; i < 7; i++) {
const cell = parseHTML(`<div class="cell"></div>`);
row.appendChild(cell);
}
calendar.append(row);
}
</script>
</body>
</html>