<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="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">
<button class="quiz__confirm">정답 확인하기</button>
<div class="quiz__result"></div>
</div>
</div>
<!-- //quiz01 -->
</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;
}
.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;
display: none;
}
const quizType = document.querySelector(".quiz__type"); //퀴즈 종류
const quizNumber = document.querySelector(".quiz__number"); //퀴즈 번호
const quizAsk = document.querySelector(".quiz__ask"); //퀴즈 질문
const quizConfirm = document.querySelector(".quiz__confirm"); //퀴즈 확인 버튼
const quizResult = document.querySelector(".quiz__result"); //퀴즈 정답
const quizDog = document.querySelector(".quiz__view .dog") //강아지
//문제 정보
const answerType = "HTML" //퀴즈 종류 데이터
const answerNum = 1; //퀴즈 번호 데이터
const answerAsk = "컨텐츠의 구조를 정의하는 마크업 언어는 무엇일까요?" //퀴즈 질문 데이터
const answerResult = "HTML"; //퀴즈 정답 데이터
//문제 출력
quizType.textContent = answerType;
quizNumber.textContent = answerNum + ". ";
quizAsk.textContent = answerAsk;
quizResult.textContent = answerResult;
//정답 확인
//정답 버튼을 클릭하면 정답 확인은 안 보이게 //숨겨진 정답은 보이게
quizConfirm.addEventListener("click", () => {
quizConfirm.style.display = "none";
quizResult.style.display = "block";
quizDog.classList.add("like");
})
//정답 확인
///숨겨진 정답을 클릭하면 정답 확인은 안 보이게 //정답 버튼은 보이게
quizResult.addEventListener("click", () => {
quizResult.style.display = "none";
quizConfirm.style.display = "block";
quizDog.classList.remove("like");
})