Quiz

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
소스 보기
Javascript
CSS

    // 문제 정보
        const infoDate = "2021년 10월";
        const infoType = "정보처리 기능사";
        const infoNum = "1.";
        const infoQuestion = "CPU의 정보처리 속도 단위 중 초당 100만 개의 연산을 수행한다는 의미의 단위는?"
        const infoAnswer = "MIPS";
        const infoDesc = "LIPS는 초당 1개, KIPS는 초당 1000개, MIPS는 초당 1000000의 연산을 수행하는것을 의미합니다."

        // 선택자 
        const quizWrap = document.querySelector(".quiz__wrap");
        const quizDate = quizWrap.querySelector(".quiz__date");
        const quizType = quizWrap.querySelector(".quiz__type");
        const quizNum = quizWrap.querySelector(".quiz__question em");
        const quizQuestion = quizWrap.querySelector(".quiz__question span");
        const quizAnswer = quizWrap.querySelector(".quiz__answer");
        const quizDesc = quizWrap.querySelector(".quiz__desc");
        const quizConfirm = quizWrap.querySelector(".quiz__confirm");
        const quizInput = quizWrap.querySelector(".quiz__input input");
        const quizAnimation = quizWrap.querySelector(".quiz__animation");

        // 문제 출력
        quizDate.innerText = infoDate;
        quizType.innerText = infoType;
        quizNum.innerText = infoNum;
        quizQuestion.innerText = infoQuestion;
        quizAnswer.innerText = infoAnswer;
        quizDesc.innerText = infoDesc;

        // 정답 해설 숨기기
        quizAnswer.classList.add("none");
        quizDesc.classList.add("none");

        // 정답 확인하기
        quizConfirm.addEventListener("click", () => {
            const userAnswer = quizInput.value;

            if(infoAnswer == userAnswer){
                quizAnimation.classList.add("like");
            } else {
                quizAnimation.classList.add("dislike");
            }
            quizConfirm.classList.add("none");
            quizInput.classList.add("none");
            quizAnswer.classList.remove("none");
            quizDesc.classList.remove("none");
        });

    @font-face {
        font-family: "nanumSquareNeo";
        font-weight: 300;
        font-style: normal;
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Light.eot");
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Light.eot?#iefix") format("embedded-opentype"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Light.woff2") format("woff2"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Light.woff") format("woff"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Light.ttf") format("truetype");
        font-display: swap;
    } 
    @font-face {
        font-family: "nanumSquareNeo";
        font-weight: 400;
        font-style: normal;
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Regular.eot");
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Regular.eot?#iefix") format("embedded-opentype"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Regular.woff2") format("woff2"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Regular.woff") format("woff"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Regular.ttf") format("truetype");
        font-display: swap;
    } 
    @font-face {
        font-family: "nanumSquareNeo";
        font-weight: 700;
        font-style: normal;
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Bold.eot");
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Bold.eot?#iefix") format("embedded-opentype"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Bold.woff2") format("woff2"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Bold.woff") format("woff"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Bold.ttf") format("truetype");
        font-display: swap;
    } 
    @font-face {
        font-family: "nanumSquareNeo";
        font-weight: 800;
        font-style: normal;
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-ExtraBold.eot");
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-ExtraBold.eot?#iefix") format("embedded-opentype"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-ExtraBold.woff2") format("woff2"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-ExtraBold.woff") format("woff"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-ExtraBold.ttf") format("truetype");
        font-display: swap;
    } 
    @font-face {
        font-family: "nanumSquareNeo";
        font-weight: 900;
        font-style: normal;
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Black.eot");
        src: url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Black.eot?#iefix") format("embedded-opentype"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Black.woff2") format("woff2"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Black.woff") format("woff"),
             url("https://cdn.jsdelivr.net/gh/websfont/nanumSquareNeo/nanumSquareNeo-Black.ttf") format("truetype");
        font-display: swap;
    } 
    .nanumSquareNeo {
        font-family: "nanumSquareNeo";
    }
    .nanumSquareNeo300 {
        font-family: "nanumSquareNeo";
        font-weight: 300;
    }
    .nanumSquareNeo400 {
        font-family: "nanumSquareNeo";
        font-weight: 400;
    }
    .nanumSquareNeo700 {
        font-family: "nanumSquareNeo";
        font-weight: 700;
    }
    .nanumSquareNeo800 {
        font-family: "nanumSquareNeo";
        font-weight: 800;
    }
    .nanumSquareNeo900 {
        font-family: "nanumSquareNeo";
        font-weight: 900;
    }
    
    /* reset */
    * {
        margin: 0;
        padding: 0;
        font-family: 'nanumSquareNeo';
        box-sizing: border-box;
        font-size: 16px;
    }
    li {
        list-style: none;
    }
    a {
        text-decoration: none;
        color: #000;
    }
    
    body {
        background-image: url(../img/img7-min.png);
        background-size: cover;
        background-position: center center;
        background-repeat: no-repeat;
        position: relative;
    }
    body::after {
        content: '';
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,0.3);
        position: absolute;
        left: 0;
        top: 0;
        z-index: -1;
    }
    
    /* common */
    .none {
        display: none !important;
    }
    
    /* header */
    #header {
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    #header h1 a {
        color: #fff;
        padding: 20px;
        font-size: 30px;
        display: inline-block;
    }
    #header nav {
        padding-right: 20px;
    }
    #header nav li {
        display: inline-block;
    }
    #header nav li a {
        padding: 10px;
        display: inline-block;
        width: 35px;
        height: 35px;
        border: 1px solid #fff;
        text-align: center;
        box-shadow: 1px 1px 0px #fff;
        line-height: 1;
        color: #fff;
    }
    #header nav li.active a {
        background-color: #fff;
        color: #000;
    }
    
    /* main */
    #main {
        min-height: 85vh;
    }
    
    /* quiz__wrap */
    .quiz__wrap {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        margin-top: 40px;
    }
    .quiz__wrap > .quiz {
        width: 500px;
        min-height: 400px;
        background-color: #fff;
        padding: 30px;
        border-radius: 20px;
        box-shadow: 2px 2px 2px rgba(0,0,0,0.1);
        margin: 10px;
    }
    .quiz__wrap > .quiz.good {
        position: relative;
    }
    .quiz__wrap > .quiz.good::before {
        content: '';
        width: 100px;
        height: 100px;
        border: 10px solid red;
        border-radius: 50%;
        position: absolute;
        left: 15px;
        top:  30px;
        z-index: 100;
    }
    .quiz__wrap > .quiz.bad {
        position: relative;
    }
    .quiz__wrap > .quiz.bad::before {
        content: '';
        width: 150px;
        height: 10px;
        background-color: red;
        position: absolute;
        left: 0;
        top: 80px;
        border-radius: 30px;
        transform: rotate(45deg);
        z-index: 100;
    }
    .quiz__wrap > .quiz.bad::after {
        content: '';
        width: 150px;
        height: 10px;
        background-color: red;
        position: absolute;
        left: 0;
        top: 80px;
        border-radius: 30px;
        transform: rotate(-45deg);
        z-index: 100;
    }
    .quiz__header {
        margin-bottom: 20px;
        color: #696969;
    }
    .quiz__date {
        display: inline-block;
        margin-right: 5px;
        color: #696969;
    }
    .quiz__type {
        color: #696969;
    }
    .quiz__main {}
    .quiz__question {
        margin-bottom: 20px;
        font-size: 24px;
        font-weight: 400;
        line-height: 1.5;
    }
    .quiz__question em {
        font-size: 24px;
        font-style: normal;
        font-weight: 400;
    }
    .quiz__question span {
        font-size: 24px;
        line-height: 1.5;
        font-weight: 400;
    }
    .quiz__img {
        margin-bottom: 10px;
    }
    .quiz__img img {
        border: 1px solid #eee;
        width: 100%;
    }
    .quiz__choice {
        margin-bottom: 20px;
    }
    .quiz__choice label {
        display: block;
        width: 100%;
        
    }
    .quiz__choice label input {
        position: absolute;
        clip: rect(0 0 0 0);
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
    }
    .quiz__choice label span {
        position: relative;
        display: flex;
        align-items: center;
        border: 1px solid #eee;
        padding: 17px;
        margin-bottom: 10px;
        border-radius: 3px;
        font-size: 16px;
        line-height: 1.4;
        font-weight: 400;
        cursor: pointer;
    }
    .quiz__choice span:hover {
        border-color: #412E91;
        color: #412E91;
        box-shadow: 1px 1px 1px #422e9168;
    }
    .quiz__choice label span::before {
        content: '';
        width: 24px;
        height: 24px;
        border-radius: 50%;
        flex-shrink: 0;
        box-shadow: inset 0 0 0 4px #412E91;
        margin-right: 15px;
        transition: all 0.3s;
    }
    .quiz__choice label input:checked + span::before {
        box-shadow: inset 0 0 0 9px #412E91;
    }
    .quiz__choice label input:checked + span {
        border-color: #412E91;
        color: #412E91;
        box-shadow: 1px 1px 1px #422e9168;
        background-color: #422e9124;
    }
    .quiz__choice .choice {
        border: 1px solid #eee;
        padding: 17px;
        margin-bottom: 10px;
        font-size: 16px;
        line-height: 1.5;
        transition: border-color 0.3s, background-color 0.3s;
        border-radius: 3px;
        color: #666
    }
    .quiz__choice .choice:hover {
        border-color: #412E91;
        cursor: pointer;
    }
    .quiz__choice .choice.correct {
        position: relative;
        border-color: #412E91;
        box-shadow: 1px 1px 1px #422e9168;
        background-color: #ccc9f624;
        color: #412E91;
        padding-right: 57px;
    }
    .quiz__choice .choice.correct::after {
        content: '';
        width: 14px;
        height: 14px;
        border: 6px solid #412E91;
        border-radius: 50%;
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
    }
    .quiz__choice .choice.incorrect {
        position: relative;
        border-color: #91323c;
        box-shadow: 1px 1px 1px #98343468;
        background-color: #f7d6d668;
        color: #91323c;
        padding-right: 57px;
    }
    .quiz__choice .choice.incorrect::before {
        content: '';
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        width: 28px;
        height: 6px;
        background-color: #91323c;
        border-radius: 4px;
        transform: rotate(45deg);
        margin-top: -3px;
    }
    .quiz__choice .choice.incorrect::after {
        content: '';
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        width: 28px;
        height: 6px;
        background-color: #91323c;
        border-radius: 4px;
        transform: rotate(-45deg);
        margin-top: -3px;
    }
    
    .quiz__animation {
        border: 1px dashed #b8a8ff;
        margin-bottom: 10px;
    }
    .quiz__input {
        margin-bottom: 10px;
    }
    .quiz__input input {
        width: 100%;
        padding: 20px;
        border: 1px solid #b8a8ff;
        border-radius: 3px;
    }
    .quiz__answer {
        background-color: #ede9ff;
        border: 1px solid #b8a8ff;
        padding: 20px;
        margin-bottom: 10px;
        line-height: 1.5;
        color: #666;
    }
    .quiz__answer::before {
        content: " 😊정답 : ";
    }
    .quiz__desc {
        border: 1px solid #eaeaea;
        padding: 20px;
        margin-bottom: 10px;
        line-height: 1.5;
        color: #666;
    }
    .quiz__desc::before {
        content: " 😊설명 : ";
    }
    .quiz__footer {}
    
    .quiz__confirm {
        background-color: #412E91;
        color: #fff;
        text-align: center;
        padding: 20px;
        display: block;
        border: 0;
        width: 100%;
        transition: all 0.3s;
        border: 1px dashed transparent;
        border-radius: 3px;
    }
    .quiz__confirm:hover {
        border: 1px dashed #412E91;
        background-color: transparent;
        color: #412E91;
        cursor: pointer;
    }
    .quiz__next {
        width: 100%;
        border: 1px dashed #412E91;
        padding: 15px 20px;
        background-color: #fff;
        color: #412E91;
        cursor: pointer;
        transition: all 0.3s
    }
    .quiz__next:hover {
        background-color: #f5f2ff;
    }
    .quiz__indicator {
        background-color: #f5f2ff;
        padding: 20px;
        border-radius: 3px;
        margin-bottom: 20px;
    }
    .quiz__indicator span {
        display: inline-block;
        width: 20px;
        height: 20px;
        border: 1px solid #412E91;
        box-shadow: 1px 1px #412E91;
    }
    .quiz__indicator span.correct {
        background-color: #412E91;
        position: relative;
    }
    .quiz__indicator span.correct::before {
        content: '';
        width: 8px;
        height: 8px;
        border: 4px solid #fff;
        border-radius: 50%;
        position: absolute;
        left: 1px;
        top: 1px;
    }
    .quiz__indicator span.incorrect {
        position: relative;
    }
    .quiz__indicator span.incorrect::before {
        content: '';
        position: absolute;
        left: 2px;
        top: 7px;
        width: 14px;
        height: 4px;
        border-radius: 4px;
        background-color: #412E91;
        transform: rotate(-45deg);
    }
    .quiz__indicator span.incorrect::after {
        content: '';
        position: absolute;
        left: 2px;
        top: 7px;
        width: 14px;
        height: 4px;
        border-radius: 4px;
        background-color: #412E91;
        transform: rotate(45deg);
    }
    .quiz__check {
        position: fixed;
        right: 20px;
        bottom: 20px;
        width: 100px;
        height: 100px;
        line-height: 100px;
        background-color: #412E91;
        color: #fff;
        border-radius: 50%;
        text-align: center;
        cursor: pointer;
        transition: all 0.3s;
        border: 1px dashed transparent;
    }
    .quiz__check:hover {
        background-color: #e1d9ff;
        border: 1px dashed #412E91;
        color: #412E91;
    }
    
    /* footer */
    #footer {
        text-align: center;
        font-size: 14px;
    }
    #footer a {
        display: block;
        color: #fff;
        padding: 40px;
    }
    #footer a:hover {
        text-decoration: underline;
        text-underline-position: under;
    }
    
    @media (max-width: 600px){
        #header {
            flex-direction: column;
        }
        #header h1 a {
            padding: 15px;
        }
        #header nav {
            padding-right: 0;
            margin-bottom: 20px;
        }
        #header nav li a {
            width: 30px;
            height: 30px;
            padding: 7px;
        }
        .quiz__wrap {
            padding: 0 16px;
            margin-top: 0;
        }
        .quiz__wrap > .quiz {
            width: 100%;
            padding: 30px 20px;
        }
        .quiz__header {
            margin-bottom: 20px;
            font-size: 14px;
        }
        .quiz__date {
            font-size: 14px;
        }
        .quiz__type {
            font-size: 14px;
        }
        .quiz__question {
            margin-bottom: 20px;
            line-height: 1.5;
            font-size: 20px;
        }
        .quiz__question em {
            font-size: 20px;
        }
        .quiz__question span {
            font-size: 20px;
        }
        .quiz__input input {
            padding: 14px;
        }
        .quiz__answer {
            padding: 14px;
        }
        .quiz__desc {
            padding: 14px;
        }
        .quiz__choice label span {
            padding: 13px;
        }
        .quiz__confirm {
            padding: 13px;
        }
    }
    
    /* modal__wrap */
    .modal__btn {
        color: #fff;
        border: 1px solid #fff;
        border-radius: 50px;
        display: inline-block;
        padding: 10px 20px;
        position: absolute;
        right: 20px;
        bottom: 20px;
        cursor: pointer;
    }
    .modal__cont {
        width: 100%;
        height: 100vh;
        background-color: rgba(0,0,0,0.7);
        position: fixed;
        left: 0;
        top: 0;
        overflow-x: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        transform: scale(0);
    }
    .modal__box {
        width: 70%;
        height: 70vh;
        border-radius: 10px;
        background-color: #ccc;
        transform: scale(0);
    }
    .modal__box .title {
        padding: 1rem;
        background-color: #1b1c2e;
        display: flex;
        align-items: center;
        color: #fff;
        height: 50px;
        border-top-left-radius: 0.5rem;
        border-top-right-radius: 0.5rem;
    }
    .modal__box .title .dot {
        width: 15px;
        height: 15px;
        background-color: #3b3d63;
        display: inline-block;
        border-radius: 50%;
        position: relative;
        margin-left: 2rem;
    }
    .modal__box .title .dot::before {
        content: '';
        position: absolute;
        left: 25px;
        top: 0;
        width: 15px;
        height: 15px;
        background-color: #3b3d63;
        border-radius: 50%;
    }
    .modal__box .title .dot::after {
        content: '';
        position: absolute;
        right: 25px;
        top: 0;
        width: 15px;
        height: 15px;
        background-color: #3b3d63;
        border-radius: 50%;
    }
    
    
    .modal__box .title .tabs {
        display: flex;
        margin-left: 50px;
    }
    .modal__box .title .tabs > div {
        color: #7a7d9d;
        background-color: #282936;
        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: pointer;
    }
    .modal__box .title .tabs > div.active {
        background-color: #1f224a;
    }
    .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: 3rem;
        margin-top: 0.2rem;
    }
    .modal__box .cont {
        background-color: #282936;
        height: 100%;
        overflow-y: auto;
        box-sizing: border-box;
        border-bottom-left-radius: 0.5rem;
        border-bottom-right-radius: 0.5rem;
    }
    .modal__box .cont > div {
        display: none;
    }
    .modal__box .cont > div.active {
        display: block;
        height: 100%;
    }
    .modal__close {
        position: absolute;
        right: 20px;
        top: 20px;
        background-color: #ffffff;
        padding: 1rem 1rem 0.8rem 1rem;
        border-radius: 5px;
        cursor: pointer;
        transition: all 0.3s;
        opacity: 0;
    }
    .modal__close:hover {
        background-color: #b9bdff;
    }
    pre code.hljs {
        margin-bottom: 0 !important;
        text-align-last: left;
    }
    
    @media (max-width: 1100px){
        .modal__box .title {
            overflow: hidden;
        }
        .modal__box .title .dot {
            display: none;
        }
        .modal__box .title .tabs {
            margin-left: 0;
        }
        .modal__box .title .tabs > div .close {
            display: none;
        }
    }
    @media (max-width: 800px){
        #header {
            width: 100%;
            text-align: center;
        }
        #header h1 {
            line-height: 1.4;
        }
        .modal__box {
            width: 96%;
        }
    }
    
    /* 모달 애니메이션 */
    .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: opacityOut 0.5s 1.5s ease forwards;
    }
    
    .modal__cont.show.hide {
        animation: foldIn 0.3s 0.5s ease backwards;
    }
    .modal__cont.show.hide .modal__box {
        animation: zoomIn 0.5s ease forwards;
    }
    .modal__cont.show.hide .modal__close {
        animation: opacityIn 0.5s ease forwards;
    }
    
    @keyframes foldOut {
        0%   {transform: scaleX(0.0001) scaleY(0);}
        50%  {transform: scaleX(0.0001) scaleY(1);}
        100% {transform: scaleX(1) scaleY(1);}
    }
    @keyframes foldIn {
        0%   {transform: scaleX(1) scaleY(1);}
        50%  {transform: scaleX(0.0001) scaleY(1);}
        100% {transform: scaleX(0.0001) scaleY(0);}
    }
    @keyframes zoomOut {
        0%   {transform: scale(0);}
        100% {transform: scale(1);}
    }
    @keyframes zoomIn {
        0%   {transform: scale(1);}
        100% {transform: scale(0);}
    }
    @keyframes opacityOut {
        0%   {opacity: 0;}
        100% {opacity: 1;}
    }
    @keyframes opacityIn {
        0%   {opacity: 1;}
        100% {opacity: 0;}
    }
X
rlanrider77@gmail.com