-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice12-4-view.html
More file actions
78 lines (73 loc) · 1.99 KB
/
practice12-4-view.html
File metadata and controls
78 lines (73 loc) · 1.99 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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>일기 보기</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0 auto;
max-width: 800px;
padding: 20px;
}
h1 {
text-align: center;
}
.diary-entry {
display: flex;
justify-content: space-between;
border-bottom: 1px solid #ccc;
padding: 10px 0;
}
.diary-number {
display: inline-flex;
justify-content: center;
align-items: center;
border: 1px solid yellowgreen ;
min-width: 1.5em; /* 숫자의 너비에 맞춤 */
min-height: 1.5em; /* 숫자의 높이에 맞춤 */
text-align: center;
line-height: 1;
padding: 0; /* 패딩 제거 */
box-sizing: border-box;
}
.diary-date {
width: 100px;
font-weight: bold;
}
.diary-content {
flex-grow: 1;
margin-left: 10px;
}
</style>
</head>
<body>
<h1>일기 보기</h1>
<hr />
<script>
function displayDiaries() {
const dates = localStorage.getItem('diaryDates');
const contents = localStorage.getItem('diaryContents');
if (!dates || !contents) {
document.write('<p>저장된 일기가 없습니다.</p>');
return;
}
const dateArray = dates.split('\n');
const contentArray = contents.split('\n');
for (let i = 0; i < dateArray.length; i++) {
document.write(`
<div class="diary-entry">
<span class="diary-number">${i + 1}</span>
<span class="diary-date">${dateArray[i]}</span>
<span class="diary-content">${contentArray[i]}</span>
</div>
`);
}
}
// 일기 목록 표시
displayDiaries();
</script>
</body>
</html>