정답입니다!
틀렸습니다!
//선택자
const quizType = document.querySelector(".quiz__type"); //퀴즈종류
const quizNumber = document.querySelector(".quiz__question .number"); //퀴즈번호
const quizAsk = document.querySelector(".quiz__question .ask"); //퀴즈 질문
const quizConfirm = document.querySelector(".quiz__answer .confirm") //정답확인버튼
const quizResult = document.querySelector(".quiz__answer .result") // 정답 결과
const quizInput = document.querySelector(".quiz__answer .input") // 사용자 정답
const quizView = document.querySelector(" .quiz__view") //강아지 //뷰어로 바꾸어서 정답과 오답박스를 출력한다.
//문제 정보
const answerType = "웹디자인기능사";
const answerNum = "2";
const answerAsk = "기업의 새로운 이념 구축에 필요한 이미지와 커뮤니케이션 시스템을 의도적, 계획적으로 만들어내는 기업이미지통합 전략은 무엇인가요?"
let answerResult = "CIP"
//문제출력
quizType.innerText = answerType;
quizNumber.innerText = answerNum + ". ";
quizAsk.innerText = answerAsk;
quizResult.textContent = "정답은 :" + answerResult + "입니다.";
//정답숨기기
quizResult.style.display = "none";
//정답 확인
quizConfirm.addEventListener("click", () => { // 정답버튼을 클릭했을 때// 화살표함수를 사용해서 메서드를 만듬
quizInput.style.display = "none";
quizResult.style.display = "block"; //none의 반대의미
quizConfirm.style.display = "none";
//사용자 정답
const userWord = quizInput.value.toLowerCase().trim(); // toLowerCase 소문자를 인식시켜준다./ trim빈칸을 인식해준다.
// answerResult = answerResult.toLowerCase().trim();
// console.log(userWord)
// console.log(answerResult)
//사용자 정답 == 문제정답
if (userWord == answerResult) {
//정답
quizView.classList.add("like");
alert("정답입니다.")
} else {
//오답
quizView.classList.add("dislike");
alert("오답입니다.")
}
});
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: border-box;
}
a, em, i {
text-decoration: none;
}
body {
background-color: #f6f6f6;
background-image:
linear-gradient(90deg, #cdcccc 0px, #cdcccc 1px, transparent 1px, transparent 99px, transparent 100px),
linear-gradient(#cdcccc 0px, #cdcccc 1px, transparent 1px, transparent 99px, transparent 100px),
linear-gradient(#e0e0e0 0px, #e0e0e0 1px, transparent 1px, transparent 99px, transparent 100px),
linear-gradient(90deg, #e0e0e0 0px, #e0e0e0 1px, transparent 1px, transparent 99px, transparent 100px),
linear-gradient(transparent 0px, transparent 5px, #f6f6f6 5px, #f6f6f6 95px, transparent 95px, transparent 100px),
linear-gradient(90deg, #e0e0e0 0px, #e0e0e0 1px, transparent 1px, transparent 99px, #e0e0e0 99px, #e0e0e0 100px),
linear-gradient(90deg, transparent 0px, transparent 5px, #f6f6f6 5px, #f6f6f6 95px, transparent 95px, transparent 100px),
linear-gradient(transparent 0px, transparent 1px, #f6f6f6 1px, #f6f6f6 99px, transparent 99px, transparent 100px),
linear-gradient(#cdcccc, #cdcccc);
background-size: 100px 100%, 100% 100px, 100% 10px, 10px 100%, 100% 100px, 100px 100%, 100px 100%, 100px 100px, 100px 100px;
}
#header {
background: #262626;
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
position: relative;
z-index: 10;
}
#header::before {
content: "";
border: 4px ridge #a3a3a3;
position: absolute;
left: 5px;
top: 5px;
width: calc(100% - 10px);
height: calc(100% - 10px);
box-sizing: border-box;
z-index: -1;
}
#header h1 {
padding: 3px 3px 6px 10px;
font-family: "DungGeunMo";
font-size: 30px;
}
#header h1 a {
color: #fff;
}
#header h1 em {
font-size: 16px;
font-style: normal;
}
@media (max-width: 600px) {
#header h1 em {
display: none;
}
}
#header nav {
padding-right: 10px;
}
#header nav li {
display: inline;
}
#header nav li a {
color: #fff;
padding: 0 10px;
border: 1px dashed #fff;
font-family: "DungGeunMo";
}
#header nav li.active a {
color: #000;
background: #fff;
}
#footer {
background: #fff;
text-align: center;
padding: 20px;
width: 100%;
box-sizing: border-box;
margin-top: 150px;
position: fixed;
left: 0;
bottom: 0;
z-index: 10000;
}
#footer a {
color: #000;
font-family: "DungGeunMo";
}
#footer a:hover {
text-decoration: underline;
}
/* quiz__wrap */
.quiz__wrap {
display: flex;
align-items: flex-start;
justify-content: center;
margin-top: 50px;
margin-bottom: 150px;
flex-wrap: wrap;
position: relative;
}
.quiz {
max-width: 500px;
width: 100%;
background-color: #fff;
border: 8px ridge #cacaca;
margin: 10px;
}
.quiz__btn {
border: 1px solid #f5f5;
border-radius: 50px;
padding: 10px 20px;
position: absolute;
bottom: 0;
right: 20px;
}
.quiz__btn:hover {
background: #f5f5f5;
}
.quiz__type {
background-color: #cacaca;
text-align: center;
display: block;
font-size: 16px;
border: 3px ridge #cacaca;
color: #3b3b3b;
font-family: "DungGeunMo";
padding: 4px;
}
.quiz__question {
border-top: 6px ridge #cacaca;
border-bottom: 6px ridge #cacaca;
padding: 20px;
font-family: "DalseoHealing";
line-height: 1.3;
}
.quiz__question .number {
color: rgb(245, 32, 32)
}
.quiz__question .ask {
display: inline;
}
.quiz__answer {
border-top: 6px ridge #cacaca;
padding: 10px;
background-color: #f5f5f5;
}
.quiz__answer .confirm {
border: 6px ridge #cacaca;
width: 100%;
font-size: 22px;
padding: 13px 20px;
background-color: #d6d6d6;
font-family: "DalseoHealing";
cursor: pointer;
}
.quiz__answer .result {
width: 100%;
font-size: 20px;
padding: 13px 20px;
border: 6px ridge #cacaca;
box-sizing: border-box;
text-align: center;
font-family: "DalseoHealing";
}
.quiz__answer .input {
width: 100%;
border: 6px ridge #cacaca;
font-size: 22px;
padding: 13px 20px;
background-color: #fff;
font-family: "DalseoHealing";
margin-bottom: 10px;
}
.quiz__view {
background-color: #f5f5f5;
font-family: "DalseoHealing";
position: relative;
/* position태그의 사용법이 궁금함 */
overflow: hidden;
}
.quiz__view .true {
width: 120px;
height: 120px;
line-height: 120px;
background-color: rgb(9, 32, 206);
color: #fff;
border-radius: 50%;
text-align: center;
position: absolute;
left: 70%;
top: 100px;
opacity: 0;
}
.quiz__view .false {
width: 120px;
height: 120px;
line-height: 120px;
background-color: rgb(191, 16, 16);
border-radius: 50%;
text-align: center;
position: absolute;
right: 70%;
top: 100px;
opacity: 0;
/*투명도*/
}
.quiz__view.like .true {
opacity: 1;
animation: wobble 0.6s;
}
.quiz__view.dislike .false {
opacity: 1;
animation: wobble 0.6s;
}
/* 객관식 박스 */
.quiz__selects {
margin: 0px 5px;
}
.quiz__selects label {
display: flex;
}
.quiz__selects label input {
position: absolute;
left: -9999px;
}
.quiz__selects label span {
font-size: 20px;
line-height: 1.3;
font-family: "DalseoHealing";
padding: 10px;
display: flex;
align-items: center;
width: 100%;
border-radius: 5px;
cursor: pointer; /* 마우스 커서 변경*/
}
.quiz__selects label span::before {
content: '';
width: 30px;
height: 30px;
border-radius: 50%;
background: #fff;
margin-right: 15px;
display: flex;
flex-shrink: 0; /* 비율에 맞춰서 빼줌*/
box-shadow: inset 0px 0px 0px 4px #a1dc0c;
transition: all 0.25s; /* 클릭될때 시간차이로 선택되게 하는 css*/
}
.quiz__selects label input:checked + span {
background-color: #F5FFE7; /* 클릭한 영역 배경색 주기*/
}
.quiz__selects label input:checked + span::before {
box-shadow: inset 0px 0px 0px 10px rgb(152, 230, 8);
}
.quiz__confirm {
width: 100%;
text-align: center;
}
.quiz__confirm .check {
font-size: 20px;
padding: 13px 20px;
border: 6px ridge #cacaca;
box-sizing: border-box;
text-align: center;
font-family: "DalseoHealing";
cursor: pointer;
margin: 40px;
transition: background 0.3s;
}
.quiz__confirm .check:hover {
background: #f5524fc4;
}
@keyframes wobble {
0% {transform: translateX(0) rotate(0deg);}
15% {transform: translateX(-25%) rotate(-5deg);}
30% {transform: translateX(20%) rotate(3deg)}
45% {transform: translateX(-15%) rotate(-3deg);}
60% {transform: translateX(10%) rotate(2deg)}
75% {transform: translateX(-5%) rotate(-1deg)}
100% {transform: translateX(0) rotate(0deg)}
}
/* scroll */
::-webkit-scrollbar-track
{
box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
background-color: #F5F5F5;
}
::-webkit-scrollbar
{
width: 10px;
background-color: #F5F5F5;
height: 10px;
}
::-webkit-scrollbar-thumb
{
border-radius: 10px;
box-shadow: inset 0 0 6px rgba(0,0,0,.3);
background-color: #282936;
}
::-webkit-scrollbar-thumb:hover {
background-color: #0f1891a7;
}
/* modal__wrap */
.modal__wrap{
}
.modal__wrap .modal__btn {
border: 2px solid #f5f5;
padding: 10px 20px;
border-radius: 50px;
position: absolute;
bottom: 50px;
right: 10px;
transition: all 0.5s ease-in-out;
cursor: pointer;
display: inline-block;
}
.modal__wrap .modal__btn:hover {
background-color: rgb(72, 208, 190);
}
.modal__cont {
width: 100%;
height: 100vh;
background-color: #f5f5;
position: fixed;
top: -40px;
left: 0;
display: flex;
align-items: center;
overflow-x: hidden;
transform: scale(0);
z-index: 1000;
}
.modal__cont .modal__box {
width: 70%;
height: 70vh;
margin: 0 auto;
background-color: rgba(255, 255, 255, 0.456);
border-radius: 0.5rem;
box-shadow: 0 10px 20px -5px hsl(180deg 2% 10%);
transform: scale(0);
}
.title {
background-color: rgba(10, 178, 255, 0.333);
border-top-left-radius: 0.5rem;
border-top-right-radius: 0.5rem;
display: flex;
align-items: center;
height: 50px;
justify-content: space-between;
}
.title .dot {
width: 15px;
height: 15px;
border: 1px solid #ff0000;
border-radius: 50%;
display: inline-block;
background-color: #ff0000;
position: relative;
}
.title .dot::before{
content: '';
width: 15px;
height: 15px;
border: 1px solid #00fc60;
border-radius: 50%;
display: inline-block;
background-color: #00fc60;
position: absolute;
left: 50px;
}
.title .dot:after {
content: '';
width: 15px;
height: 15px;
border: 1px solid #ffff00;
border-radius: 50%;
display: inline-block;
background-color: #ffff00;
position: absolute;
left: 25px;
}
.tabs {
display: flex;
}
.tabs > div {
color: #7A7D9D;
background-color: #1f224a;
padding: 0.35rem 0.8rem 0.25rem 0.8rem;
margin-right: 0.5rem;
display: flex;
align-items: center;
border-radius: 0.4rem;
text-transform: uppercase;
cursor: grab;
}
.tabs > div.active {
background-color: #fff;
}
.title .plus {
border: 1px solid #000;
padding: 0.4rem;
border-radius: 10px;
background-color: #1f224a;
color: #fff;
}
.modal__box .title .tabs > div.active {
background-color: #fff;
}
.modal__box .title .tabs > div em {
font-style: normal;
}
.modal__box .title .tabs > div .favicon {
margin-right: 0.4rem;
margin-top: 0.2rem;
}
.modal__box .title .tabs > div .close {
margin-left: 4rem;
}
.modal__box .cont {
background-color: #282936;
height: 100%;
box-sizing: border-box;
border-bottom-left-radius: 0.5rem;
border-bottom-right-radius: 0.5rem;
overflow-y: auto;
}
.modal__box .cont > div{
display: none;
}
.modal__box .cont > div.active {
display: block;
height: 100%;
}
.modal__cont .modal__close {
border: 1px solid #000;
position: absolute;
right: 20px;
top: 100px;
padding: 10px 20px;
border-radius: 50px;
background-color: #f5f5;
transition: all 0.5s ease;
}
.modal__cont .modal__close:hover {
background-color: #fff;
}
.modal__close {
position: absolute;
right: 10px;
top: 10px;
background-color: #1f224a;
padding: 1rem 1rem 0.8rem 1rem;
border-radius: 5px;
box-shadow: 0 3px 5px -5px hsl(180deg 2% 10%);
cursor: pointer;
transition: all 0.3s;
opacity: 0;
}
.modal__close:hover{
background-color: #13142d7d;
}
.modal__close svg{
color: #fff;
}
/* 모달 애니메이션 */
.modal__cont.show { /*전체 배경*/
animation: foldOut 1s ease forwards;
}
.modal__cont.show .modal__box { /*스크립트 배경*/
animation: zoomOut 0.5s 1s ease forwards; /*초를 두개써서딜레이를 줄 수 있다*/
}
.modal__cont.show .modal__close { /* 닫기버튼*/
animation: closeOut 0.6s 1.5s ease forwards;
}
.modal__cont.show.hide {
animation: foldIn 0.3s 0.3s ease backwards;
}
.modal__cont.show.hide .modal__box{
animation: zoomIn 0.5s 1s ease backwards;
}
.modal__cont.show.hide .modal__close { /* 닫기버튼*/
animation: closeIn 0.3s 0.6s ease backwards;
opacity: 0;
}
@keyframes foldOut {
0% {transform: scaleX(0) scaleY(0.001);}
50% {transform: scaleX(1) scaleY(0.001);}
100% {transform: scaleX(1) scaleY(1);}
}
@keyframes closeOut {
0% {opacity: 0;}
100% {opacity: 1;}
}
@keyframes foldIn {
0% {transform: scaleX(1) scaleY(1);}
50% {transform: scaleX(1) scaleY(0.001);}
100% {transform: scaleX(0) scaleY(0.001);}
}
@keyframes zoomOut {
0% {transform: scale(0);}
100% {transform: scale(1);}
}
@keyframes zoomIn {
100% {transform: scale(1);}
0% {transform: scale(0);}
}
/* dog */
.dog .tail,
.dog .chin,
.dog .tongue::before,
.dog .tongue::after,
.dog .mouth,
.dog .nose,
.dog .teardrop,
.dog .eyes,
.dog .face::before,
.dog .face::after,
.dog .ears::before,
.dog .ears::after {
transition: 0.2s ease-in;
}
.dog {
padding-top: 50px;
}
.dog .head,
.dog .body {
position: relative;
width: 115px;
}
.dog .head {
height: 115px;
border-radius: 50% 50% 0 0;
margin: 0 auto;
}
.dog .ears {
position: relative;
top: -14%;
width: 100%;
}
.dog .ears::before,
.dog .ears::after {
content: "";
position: absolute;
top: 0;
width: 35px;
height: 70px;
background: #CB7A1D;
border-top: 11px solid #F7AA2B;
border-left: 7px solid #F7AA2B;
border-right: 7px solid #F7AA2B;
}
.dog .ears::before {
left: 0;
border-radius: 50% 45% 0 0;
}
.dog .ears::after {
right: 0;
border-radius: 45% 50% 0 0;
}
.dog .face {
position: absolute;
background: #F7AA2B;
width: 100%;
height: 100%;
border-radius: 50% 50% 0 0;
}
.dog .face::before,
.dog .face::after {
content: "";
display: block;
margin: auto;
background: #FEFEFE;
}
.dog .face::before {
width: 15px;
height: 35px;
margin-top: 24px;
border-radius: 20px 20px 0 0;
}
.dog .face::after {
position: absolute;
bottom: -1px;
left: 0;
right: 0;
width: 60px;
height: 65px;
border-radius: 45% 45% 0 0;
}
.dog .eyes {
position: relative;
top: 29%;
text-align: center;
}
.dog .eyes::before,
.dog .eyes::after {
content: "";
display: inline-block;
width: 12px;
height: 12px;
border-radius: 100%;
background: #451d1c;
margin: 0 14.5%;
}
.dog .teardrop {
position: absolute;
top: 125%;
left: 19%;
width: 6px;
height: 6px;
border-radius: 0 50% 50% 50%;
transform: rotate(45deg);
background: #FEFEFE;
visibility: hidden;
}
.dog .nose {
position: relative;
top: 35%;
width: 16px;
height: 8px;
border-radius: 35px 35px 65px 65px;
background: #451d1c;
margin: auto;
}
.dog .mouth {
position: relative;
top: 34.5%;
width: 4px;
height: 6px;
margin: 0 auto;
text-align: center;
background: #451d1c;
}
.dog .mouth::before,
.dog .mouth::after {
content: "";
position: absolute;
top: -4px;
width: 18px;
height: 18px;
border-radius: 50%;
border: 4px solid #451d1c;
border-left-color: transparent;
border-top-color: transparent;
z-index: 2;
}
.dog .mouth::before {
transform: translateX(-89%) rotate(45deg);
}
.dog .mouth::after {
transform: translateX(-2px) rotate(45deg);
}
.dog .tongue {
position: relative;
z-index: 1;
}
.dog .tongue::before,
.dog .tongue::after {
content: "";
position: absolute;
}
.dog .tongue::before {
top: 10px;
left: -7px;
width: 18px;
height: 0;
border-radius: 50%;
background: #451d1c;
z-index: -1;
}
.dog .tongue::after {
top: 14px;
left: -4px;
width: 12px;
height: 0;
border-radius: 20px;
background: #F5534F;
z-index: 5;
}
.dog .chin {
position: relative;
top: 47.5%;
margin: 0 auto;
width: 12px;
height: 12px;
border-top: 10px solid #e8e7ec;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-radius: 2px;
z-index: 0;
}
.dog .body {
position: relative;
height: 139px;
margin: auto;
z-index: 0;
}
.dog .body::before,
.dog .body::after {
content: "";
position: absolute;
top: -1px;
left: 0;
right: 0;
bottom: 0;
display: block;
width: 100%;
margin: auto;
background: #F7AA2B;
}
.dog .body::after {
top: -2px;
bottom: -1px;
width: 60px;
background: #FEFEFE;
}
.dog .tail {
position: absolute;
left: -60%;
bottom: 1px;
background: #F7AA2B;
width: 93px;
height: 15px;
transform: rotate(45deg);
transform-origin: 100% 50%;
border-radius: 25px 0 0 25px;
z-index: -2;
animation: movetail 0.1s linear infinite alternate forwards;
}
.dog .legs {
position: absolute;
bottom: 0;
left: -10%;
width: 120%;
height: 15%;
background: #F7AA2B;
border-radius: 10px 10px 0 0;
}
.dog .legs::before,
.dog .legs::after {
content: "";
position: absolute;
bottom: 1px;
background: #CB7A1D;
z-index: -1;
}
.dog .legs::before {
left: -7.5%;
width: 115%;
height: 55%;
border-radius: 5px 5px 0 0;
}
.dog .legs::after {
left: -3.5%;
width: 107%;
height: 250%;
border-radius: 20px 20px 35px 35px;
}
.like .dog .face::before {
margin-top: 10px;
}
.like .dog .face::after {
height: 85px;
}
.like .dog .eyes {
top: 13%;
}
.like .dog .eyes::before,
.like .dog .eyes::after {
width: 18px;
height: 5px;
margin: 0px 12.5%;
transform: rotate(-37.5deg);
border-radius: 20px;
}
.like .dog .eyes::after {
transform: rotate(37.5deg);
}
.like .dog .nose {
top: 18%;
}
.like .dog .mouth {
top: 16.5%;
}
.like .dog .tongue::before {
height: 12px;
}
.like .dog .tongue::after {
height: 24px;
animation: movetongue 0.1s linear 0.35s infinite alternate forwards;
}
.like .dog .chin {
top: 34%;
}
.like .dog .tail {
animation: movetail 0.1s linear infinite alternate forwards;
}
.dislike .dog .ears::before {
transform: rotate(-50deg) translate(-7px, 2px);
}
.dislike .dog .ears::after {
transform: rotate(50deg) translate(7px, 2px);
}
.dislike .dog .face::before {
margin-top: 28px;
}
.dislike .dog .face::after {
height: 55px;
}
.dislike .dog .eyes {
top: 38%;
}
.dislike .dog .eyes::before,
.dislike .dog .eyes::after {
width: 18px;
height: 5px;
margin: 0px 14.5%;
transform: rotate(-37.5deg);
border-radius: 20px;
}
.dislike .dog .eyes::after {
transform: rotate(37.5deg);
}
.dislike .dog .teardrop {
animation: cry 0.1s ease-in 0.25s forwards;
}
.dislike .dog .nose {
top: 44%;
}
.dislike .dog .mouth {
top: 42%;
}
.dislike .dog .chin {
top: 52%;
}
.dislike .dog .tail {
transform: rotate(0);
animation: none;
}
@keyframes movetongue {
100% {
height: 27px;
}
}
@keyframes movetail {
0% {
transform: rotate(37deg);
}
100% {
transform: rotate(52deg);
}
}
@keyframes cry {
100% {
visibility: visible;
}
}
//강아지 부분
<main id="main">
<div class="quiz__wrap">
<div class="quiz">
<span class="quiz__type"></span>
<h2 class="quiz__question">
<span class="number"></span>
<div class="ask">
</div>
</h2>
<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="confirm">정답 확인하기</button>
<div class="result"></div>
</div>
</div>
</div>
</main>