<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="dog">
<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='legs'></div>
</div>
</div>
</div>
</div>
<div class="quiz__answer">
<button class="quiz__confirm">정답 확인하기</button>
<div class="quiz__result"></div>
</div>
</div>
</div>
.quiz__wrap {
display: flex;
align-items: center;
justify-content: center;
margin-top: 150px;
}
.quiz {
max-width: 500px;
width: 100%;
background: #fff;
border: 8px ridge #cacaca;
flex-wrap: wrap;
margin: 10px;
}
.quiz__Type {
background: #cacaca;
text-align: center;
font-size: 14px;
color: #3b3b3b;
border: 3px ridge #cacaca;
padding: 3px 0;
position: relative;
}
.quiz__question {
border-top: 6px ridge #cacaca;
border-bottom: 6px ridge #cacaca;
padding: 13px 30px;
font-size: 24px;
line-height: 1.4
}
.quiz__Type::before {
content: '';
position: absolute;
left: 2px;
top: 2px;
width: 5px;
height: 5px;
border: 6px ridge #cacaca;
}
.quiz__Type::after {
content: '';
position: absolute;
right: 2px;
top: 2px;
width: 5px;
height: 5px;
border: 6px ridge #cacaca;
}
.quiz__number {
font-family: 'Cafe24Dangdanghae';
color: #bababa;
}
.quiz__ask {
font-family: 'Cafe24Dangdanghae';
color: #000;
}
.quiz__view {
background-color: #f5f5f5;
position: relative;
}
.quiz__view .true {
position: absolute;
left: 70%;
top: 100px;
width: 100px;
height: 100px;
border-radius: 50%;
z-index: 100;
line-height: 100px;
text-align: center;
color: #fff;
background-color: #f5534f;
opacity: 0;
}
.quiz__view .false {
position: absolute;
right: 70%;
top: 100px;
width: 100px;
height: 100px;
background-color: #fff;
border-radius: 50%;
z-index: 100;
line-height: 100px;
text-align: center;
color: #f5534f;
background-color: #fff;
opacity: 0;
}
.quiz__answer {
background-color: #f5f5f5;
border-top: 6px ridge #cacaca;
padding: 10px;
}
.quiz__confirm {
border: 6px ridge #cacaca;
width: 100%;
font-size: 22px;
padding: 13px 20px;
background: #d6d6d6;
text-shadow: 1px 1px 1px #fff;
transition: all 0.3s;
cursor: pointer;
}
.quiz__confirm:hover {
background: #b3b3b3;
}
.quiz__result {
border: 6px ridge #cacaca;
width: 100%;
font-size: 22px;
padding: 13px 20px;
background: #fff;
text-align: center;
text-shadow: 1px 1px 1px #fff;
font-family: 'Cafe24Dangdanghae';
display: none;
color: #000;
}
.quiz__input {
border: 6px ridge #cacaca;
width: 100%;
font-size: 22px;
padding: 13px 20px;
background: #fff;
text-shadow: 1px 1px 1px #fff;
font-family: 'Cafe24Dangdanghae';
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: "javascript",
answerNum: 1,
answerAsk: "객체 기반의 스크립트 프로그래밍 언어는 무엇입니까?",
answerResult: "javascript"
},
{
answerType: "html",
answerNum: 2,
answerAsk: "보여지는 브라우저의 구조를 설계하며 웹 피이지를 위한 마크업 언어는 무엇입니까?",
answerResult: "css"
},
{
answerType: "css",
answerNum: 3,
answerAsk: " HTML이나 XML로 작성된 문서의 표시 방법을 기술하기 위한 스타일 시트 언어는?",
answerResult: "css"
},
];
//문제출력
// quizType[0].textContent = quizInfo[0].answerType;
// quizType[1].textContent = quizInfo[1].answerType;
// quizType[2].textContent = quizInfo[2].answerType;
// quizNumber[0].textContent = quizInfo[0].answerNum + ". ";
// quizNumber[1].textContent = quizInfo[1].answerNum + ". ";
// quizNumber[2].textContent = quizInfo[2].answerNum + ". ";
// quizAsk[0].textContent = quizInfo[0].answerAsk
// quizAsk[1].textContent = quizInfo[1].answerAsk
// quizAsk[2].textContent = quizInfo[2].answerAsk
// quizResult[0].textContent = quizInfo[0].answerResult
// quizResult[1].textContent = quizInfo[1].answerResult
// quizResult[2].textContent = quizInfo[2].answerResult
//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(function(el){
// el.
// })
quizResult.forEach(el =>{
el.style.display = "none"
});
quizConfirm.forEach((e, i) =>{
e.addEventListener("click", () =>{
// e.style.display = "none";
// quizResult[i].style.display="block";
const userWord = quizInput[i].value.toLowerCase().trim();
if(userWord==quizInfo[i].answerResult){
quizView[i].classList.add("like")
quizResult[i].style.display="none"
}else {
quizView[i].classList.add("dislike")
quizConfirm[i].style.display="none"
quizResult[i].style.display="block"
quizInput[i].style.display="none"
}
})
})