-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpepero_make1.html
248 lines (223 loc) · 6.54 KB
/
pepero_make1.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>빼빼로 만들기 1단계</title>
</head>
<!--css 파일-->
<style>
body {
/* font-family: "Noto Sans KR", sans-serif;
align-items: center; */
font-family: "Noto Sans KR", sans-serif;
align-items: center;
background-color: #faf9f5;
margin: 0;
display: flex;
justify-content: center;
height: 100vh;
}
.make1-form {
width: 390px;
height: 844px;
display: flex;
flex-direction: column;
align-items: center;
/* justify-content: space-between; */
}
.header {
padding-top: 70px;
align-items: center;
justify-content: center;
}
#text1 {
font-size: 20px;
font-weight: 600;
text-align: center;
color: #4b2a0b;
}
#text2 {
font-size: 12px;
font-weight: 600;
text-align: center;
color: #885c33;
}
.make1 {
height: 480px;
display: flex;
/* justify-content: space-between; */
width: 100%;
margin-top: 30px;
}
.show {
margin-left: 80px;
width: 48%;
padding: 10px;
}
#pepero {
height: 477px;
width: 40px;
padding-left: 10px;
position: absolute;
z-index: 1;
}
#make1Image {
position: relative;
margin-left: 7px;
}
#make1Image.img {
position: absoulute;
z-index: 2;
top: 0;
left: 0;
}
.option {
width: 48%;
padding: 10px;
padding-top: 5px;
margin-right: 35px;
}
.option button {
width: 117px;
height: 73px;
display: block;
background-color: #f7f7f7;
margin: 20px 0;
font-size: 18px;
font-weight: 600;
border-radius: 16px;
border: 1px solid #cbcbcb;
}
.next {
width: 100%;
padding-top: 70px;
display: flex;
justify-content: center;
align-items: center;
}
.return,
.make2 {
width: 120px;
height: 44px;
margin-top: 5px;
margin-left: 30px;
border-radius: 16px;
border: 1px solid;
}
.return {
margin-left: 5px;
background-color: #401f00;
color: white;
font-size: 15px;
font-weight: 600;
}
.make2 {
background-color: #eaded8;
color: #401f00;
font-size: 15px;
font-weight: 600;
border: none;
}
</style>
<body>
<!--전체 화면을 포함하는 section 박스-->
<section class="make1-form">
<!--header를 포함하는 div 태그-->
<div class="header">
<p id="text1">1단계 : 빼빼로 코팅하기!</p>
<p id="text2">
어떤 초콜릿이든 빼빼로를 코팅할까요?<br />버튼을 눌러 선택해주세요!
</p>
</div>
<!--빼빼로를 만드는 화면을 포함하는 div 태그-->
<div class="make1">
<!--만든 빼빼로를 보여주는 화면을 포함하는 div 태그-->
<div class="show">
<img src="img/pepero.png" id="pepero" />
<div id="make1Image"></div>
</div>
<!--버튼을 옵션을 선택하는 화면을 포함하는 div태그-->
<div class="option">
<button type="button" id="choco">초코</button>
<button type="button" id="strawberry">딸기</button>
<button type="button" id="whitechoco">화이트 초코</button>
<button type="button" id="greentea">녹차</button>
<button type="button" id="blueberry">블루베리</button>
</div>
</div>
<!--다음 과정을 선택할 버튼을 포함하는 div 태그-->
<div class="next">
<button type="button" class="return">원상태로</button>
<button type="button" class="make2" id="nextButton">다음 단계</button>
</div>
</section>
<script type="text/javascript">
const chocoButton = document.getElementById("choco");
const strawberryButton = document.getElementById("strawberry");
const whiteChocoButton = document.getElementById("whitechoco");
const greenTeaButton = document.getElementById("greentea");
const blueberryButton = document.getElementById("blueberry");
const make1Image = document.getElementById("make1Image");
const buttons = [
chocoButton,
strawberryButton,
whiteChocoButton,
greenTeaButton,
blueberryButton,
];
buttons.forEach((button) => {
button.style.backgroundColor = "#f7f7f7";
button.style.color = "#000";
});
chocoButton.addEventListener("click", function () {
changeButtonStyle(chocoButton, "#7D3C0A", "white");
loadImage("img/choco.png");
});
strawberryButton.addEventListener("click", function () {
changeButtonStyle(strawberryButton, "#FFC2C2", "white");
loadImage("img/strawberry.png");
});
whiteChocoButton.addEventListener("click", function () {
changeButtonStyle(whiteChocoButton, "#EDEBC5", "white");
loadImage("img/whitechoco.png");
});
greenTeaButton.addEventListener("click", function () {
changeButtonStyle(greenTeaButton, "#C1C890", "white");
loadImage("img/greentea.png");
});
blueberryButton.addEventListener("click", function () {
changeButtonStyle(blueberryButton, "#BCBED7", "white");
loadImage("img/blueberry.png");
});
function changeButtonStyle(button, backgroundColor, textColor) {
// 선택된 버튼의 스타일 변경
button.style.backgroundColor = backgroundColor;
button.style.color = textColor;
// 다른 버튼의 스타일 초기화
buttons.forEach((btn) => {
if (btn !== button) {
btn.style.backgroundColor = "#f7f7f7";
btn.style.color = "#000";
}
});
}
function loadImage(imageSrc) {
const newImage = document.createElement("img");
newImage.src = imageSrc;
newImage.style.position = "absolute";
newImage.style.zIndex = 1;
newImage.style.top = "0";
newImage.style.left = "0";
make1Image.style.position = "relative";
make1Image.innerHTML = ""; // 이전 이미지를 제거
make1Image.appendChild(newImage);
}
document
.getElementById("nextButton")
.addEventListener("click", function () {
window.location.href = "pepero_make2.html";
});
</script>
</body>
</html>