-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_display.html
More file actions
79 lines (76 loc) · 2.41 KB
/
Copy pathexample_display.html
File metadata and controls
79 lines (76 loc) · 2.41 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
<!DOCTYPE html>
<html lang="kr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>보기 감추기</title>
<style>
body{
display: flex;
justify-content: center;
}
.container{
width: 450px;
height: 550px;
}
img{
width: 400px;
height: 300px;
}
.parents{
width: 400px;
height: 300px;
position: relative;
}
button{
opacity: 80%;
}
.parents .btn .open{
left: 10px;
bottom: 10px;
position: absolute;
}
.box{
display: none;
width: 400px;
}
.close{
display: none;
}
</style>
</head>
<body>
<div class="container">
<div class="parents">
<img src="images/flower1.jpg" alt="">
<div class="btn">
<button type="button" class="open">상세 설명 보기</button>
</div>
</div>
<div class="box">
<h4>민들레</h4>
<p>어디선가 매우 흔하게 보이는 잡초로서 바닥에 딱 붙어서 꽃봉오리 하나가 쑥 올라온다. 톱니 모양의 잎새와 눈에 확 띄는 노란 꽃이 인상적이다. 특히 꽃이 지고나면 솜털모양의 깃을 가진 씨앗들이 나오는데 바람을 타고 날아가서 널리 퍼진다.</p>
</div>
<button type="button" class="close">상세 설명 닫기</button>
</div>
<script>
// 1.event가 무엇인지 찾는다.
// 2.document를 이용하여 변수 처리한다.
// 3.addEventListener를 이용하여 화살표 함수를 사용한다.
// 4.if,for,switch는 문제에 맞추어 사용한다.
let box = document.querySelector(".box");
let open = document.querySelector(".open");
let close = document.querySelector(".close");
open.addEventListener("click",() => {
box.style.display = "block";
open.style.display = "none";
close.style.display = "block";
})
close.addEventListener("click",() => {
box.style.display = "none";
open.style.display = "block";
close.style.display = "none";
})
</script>
</body>
</html>