<div class="quiz__wrap">
<div class="quiz">
<h2 class="quiz__type"></h2>
<h3 class="quiz__question">
<span class="quiz__number"></span>
<span class="quiz__ask"></span>
</h3>
<div class="quiz__view">
<div class="true">정답입니다!</div>
<div class="false">오답입니다!</div>
<div class="dog">
<div class="head">
<div class="ears"></div>
<div class="face"></div>
<div class="eyes">
<div class="teardrop"></div>
</div>
<div class="nose"></div>
<div class="mouth">
<div class="tongue"></div>
</div>
<div class="chin"></div>
</div>
<div class="body">
<div class="tail"></div>
<div class="legs"></div>
</div>
</div>
</div>
<div class="quiz__answer">
<input type="text" class="quiz__input" placeholder="정답을 적어주세요!">
<button class="quiz__confirm">정답 확인하기</button>
<div class="quiz__result"></div>
</div>
</div>
<!-- //quiz01 -->
<div class="quiz">
<h2 class="quiz__type"></h2>
<h3 class="quiz__question">
<span class="quiz__number"></span>
<span class="quiz__ask"></span>
</h3>
<div class="quiz__view">
<div class="true">정답입니다!</div>
<div class="false">오답입니다!</div>
<div class="dog">
<div class="head">
<div class="ears"></div>
<div class="face"></div>
<div class="eyes">
<div class="teardrop"></div>
</div>
<div class="nose"></div>
<div class="mouth">
<div class="tongue"></div>
</div>
<div class="chin"></div>
</div>
<div class="body">
<div class="tail"></div>
<div class="legs"></div>
</div>
</div>
</div>
<div class="quiz__answer">
<input type="text" class="quiz__input" placeholder="정답을 적어주세요!">
<button class="quiz__confirm">정답 확인하기</button>
<div class="quiz__result"></div>
</div>
</div>
<!-- //quiz02 -->
<div class="quiz">
<h2 class="quiz__type"></h2>
<h3 class="quiz__question">
<span class="quiz__number"></span>
<span class="quiz__ask"></span>
</h3>
<div class="quiz__view">
<div class="true">정답입니다!</div>
<div class="false">오답입니다!</div>
<div class="dog">
<div class="head">
<div class="ears"></div>
<div class="face"></div>
<div class="eyes">
<div class="teardrop"></div>
</div>
<div class="nose"></div>
<div class="mouth">
<div class="tongue"></div>
</div>
<div class="chin"></div>
</div>
<div class="body">
<div class="tail"></div>
<div class="legs"></div>
</div>
</div>
</div>
<div class="quiz__answer">
<input type="text" class="quiz__input" placeholder="정답을 적어주세요!">
<button class="quiz__confirm">정답 확인하기</button>
<div class="quiz__result"></div>
</div>
</div>
<!-- //quiz03 -->
<div class="quiz">
<h2 class="quiz__type"></h2>
<h3 class="quiz__question">
<span class="quiz__number"></span>
<span class="quiz__ask"></span>
</h3>
<div class="quiz__view">
<div class="true">정답입니다!</div>
<div class="false">오답입니다!</div>
<div class="dog">
<div class="head">
<div class="ears"></div>
<div class="face"></div>
<div class="eyes">
<div class="teardrop"></div>
</div>
<div class="nose"></div>
<div class="mouth">
<div class="tongue"></div>
</div>
<div class="chin"></div>
</div>
<div class="body">
<div class="tail"></div>
<div class="legs"></div>
</div>
</div>
</div>
<div class="quiz__answer">
<input type="text" class="quiz__input" placeholder="정답을 적어주세요!">
<button class="quiz__confirm">정답 확인하기</button>
<div class="quiz__result"></div>
</div>
</div>
<!-- //quiz04 -->
<div class="quiz">
<h2 class="quiz__type"></h2>
<h3 class="quiz__question">
<span class="quiz__number"></span>
<span class="quiz__ask"></span>
</h3>
<div class="quiz__view">
<div class="true">정답입니다!</div>
<div class="false">오답입니다!</div>
<div class="dog">
<div class="head">
<div class="ears"></div>
<div class="face"></div>
<div class="eyes">
<div class="teardrop"></div>
</div>
<div class="nose"></div>
<div class="mouth">
<div class="tongue"></div>
</div>
<div class="chin"></div>
</div>
<div class="body">
<div class="tail"></div>
<div class="legs"></div>
</div>
</div>
</div>
<div class="quiz__answer">
<input type="text" class="quiz__input" placeholder="정답을 적어주세요!">
<button class="quiz__confirm">정답 확인하기</button>
<div class="quiz__result"></div>
</div>
</div>
<!-- //quiz05 -->
<div class="quiz">
<h2 class="quiz__type"></h2>
<h3 class="quiz__question">
<span class="quiz__number"></span>
<span class="quiz__ask"></span>
</h3>
<div class="quiz__view">
<div class="true">정답입니다!</div>
<div class="false">오답입니다!</div>
<div class="dog">
<div class="head">
<div class="ears"></div>
<div class="face"></div>
<div class="eyes">
<div class="teardrop"></div>
</div>
<div class="nose"></div>
<div class="mouth">
<div class="tongue"></div>
</div>
<div class="chin"></div>
</div>
<div class="body">
<div class="tail"></div>
<div class="legs"></div>
</div>
</div>
</div>
<div class="quiz__answer">
<input type="text" class="quiz__input" placeholder="정답을 적어주세요!">
<button class="quiz__confirm">정답 확인하기</button>
<div class="quiz__result"></div>
</div>
</div>
<!-- //quiz06 -->
</div>
.quiz__wrap {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
.quiz {
max-width: 500px;
width: 100%;
background: #fff;
border: 8px ridge #CACACA;
margin: 10px;
}
.quiz__type {
background: #CACACA;
text-align: center;
font-size: 14px;
color: #3B3B3B;
border: 3px ridge #CACACA;
padding: 3px 0;
position: relative;
}
.quiz__type::after {
content: '';
position: absolute;
right: 1px;
top: 1px;
width: 5px;
height: 5px;
border: 10px ridge #940728;
}
.quiz__type::before {
content: '';
position: absolute;
left: 1px;
top: 1px;
width: 5px;
height: 5px;
border: 10px ridge #940728;
}
.quiz__question {
border-top: 6px ridge #cacaca;
border-bottom: 6px ridge #cacaca;
padding: 13px 30px;
font-size: 24px;
line-height: 1.4;
}
.quiz__number {
font-family: 'Cafe24Dangdanghae';
color: #940728;
}
.quiz__ask {
font-family: 'Cafe24Dangdanghae';
}
.quiz__view {
background: #f5f5f5;
position: relative;
}
.quiz__view .true {
position: absolute;
left: 70%;
top: 100px;
width: 120px;
height: 120px;
border-radius: 50%;
z-index: 100;
line-height: 120px;
text-align: center;
color: #fff;
background: #F5534F;
opacity: 0;
}
.quiz__view .false {
position: absolute;
right: 70%;
top: 100px;
width: 120px;
height: 120px;
border-radius: 50%;
z-index: 100;
line-height: 120px;
text-align: center;
background: #fff;
color: #F5534F;
opacity: 0;
}
.quiz__view.like .true {
opacity: 1;
animation: wobble 0.6s;
}
.quiz__view.dislike .false {
opacity: 1;
animation: wobble 0.6s;
}
@keyframes wobble {
0% {transform: translateZ(0)}
15% {transform: translate3d(-25%, 0, 0) rotate(-5deg)}
30% {transform: translate3d(20%, 0, 0) rotate(3deg)}
45% {transform: translate3d(-15%, 0, 0) rotate(-3deg)}
60% {transform: translate3d(10%, 0, 0) rotate(2deg)}
75% {transform: translate3d(-5%, 0, 0) rotate(-1deg)}
100% {transform: translateZ(0)}
}
.quiz__answer {
background: #f5f5f5;
border-top: 6px ridge #cacaca;
padding: 10px;
}
.quiz__confirm {
border: 6px ridge #cacaca;
width: 100%;
font-size: 22px;
padding: 13px 20px;
background: #d6d6d6;
font-family: 'Cafe24Dangdanghae';
text-shadow: 1px 1px 1px #fff;
cursor: pointer;
}
.quiz__confirm:hover {
background: #b3b3b3;
}
.quiz__result {
text-align: center;
border: 6px ridge #cacaca;
width: 100%;
font-size: 22px;
padding: 13px 20px;
background: #fff;
font-family: 'Cafe24Dangdanghae';
text-shadow: 1px 1px 1px #fff;
}
.quiz__input {
text-align: center;
width: 100%;
border: 6px ridge #cacaca;
font-size: 22px;
padding: 13px 20px;
background: #fff;
font-family: 'Cafe24Dangdanghae';
text-shadow: 1px 1px 1px #fff;
margin-bottom: 10px;
}
const quizType = document.querySelectorAll(".quiz__type"); //퀴즈 종류들
const quizNumber = document.querySelectorAll(".quiz__number"); //퀴즈 번호
const quizAsk = document.querySelectorAll(".quiz__ask"); //퀴즈 질문
const quizConfirm = document.querySelectorAll(".quiz__confirm"); //퀴즈 확인 버튼
const quizResult = document.querySelectorAll(".quiz__result"); //퀴즈 정답
const quizView = document.querySelectorAll(".quiz__view") //강아지
const quizInput = document.querySelectorAll(".quiz__input") //인풋박스
//문제정보
const quizInfo = [
{answerType : "HTML", answerNum : 1, answerAsk : "네비게이션을 돕거나 소개를 나타내는 그룹을 표현하는 태그는 무엇인가요?", answerResult : "header"},
{answerType : "HTML", answerNum : 2, answerAsk : "다른 페이지나 같은 페이지 안에 다른 부분으로 이어주는 네비게이션 링크로 구성된 섹션을 표현하는 태그는 무엇인가요?", answerResult : "nav"},
{answerType : "HTML", answerNum : 3, answerAsk : "문서내에서 독립적인 컨텐츠를 나타내는 태그는 무엇인가요?", answerResult : "article"},
{answerType : "HTML", answerNum : 4, answerAsk : "문서내에서 일반적인 섹션을 나타내는 태그는 무엇인가요?", answerResult : "section"},
{answerType : "HTML", answerNum : 5, answerAsk : "주로 하단에서 저작권 정보나 서비스 제공자 정보를 나타내는 태그는 무엇인가요?", answerResult : "footer"},
{answerType : "HTML", answerNum : 6, answerAsk : "문서의 내용 즉 컨텐츠들의 그룹을 나타내는 태그를 무엇인가요?", answerResult : "main"}
];
//문제출력
//for문
// for(let i=0; i<quizInfo.length; i++){
// quizType[i].textContent = quizInfo[i].answerType;
// quizNumber[i].textContent = quizInfo[i].answerNum + ". ";
// quizAsk[i].textContent = quizInfo[i].answerAsk;
// quizResult[i].textContent = quizInfo[i].answerResult;
// };
//forEach문
quizInfo.forEach((el, i) => {
quizType[i].textContent = quizInfo[i].answerType;
quizNumber[i].textContent = quizInfo[i].answerNum + ". ";
quizAsk[i].textContent = quizInfo[i].answerAsk;
quizResult[i].textContent = "정답은 : " + quizInfo[i].answerResult + " 입니다.";
})
//정답숨기기
quizResult.forEach(el => {
el.style.display = "none";
});
//정답 확인
quizConfirm.forEach((btn, num) => {
btn.addEventListener("click", () => {
// btn.style.display = "none";
// quizResult[i].style.display = "block";
//사용자 정답 == quizInfo 정답
const userWord = quizInput[num].value.toLowerCase().trim();
if(userWord == quizInfo[num].answerResult){
quizView[num].classList.add("like");
quizConfirm[num].style.display = "none";
} else {
quizView[num].classList.add("dislike");
quizConfirm[num].style.display = "none";
quizInput[num].style.display = "none";
quizResult[num].style.display = "block";
}
})
})