纯前端答题交互(可单选、多选) | 您所在的位置:网站首页 › 抽奖选项 › 纯前端答题交互(可单选、多选) |
纯前端答题交互(可单选、多选),用户确定选项可及时判断对错及提示功能; 题库可提前使用excel表格录好,在线使用Exel转JSON格式,网址:在线Excel、CSV转JSON格式-BeJSON.com 可以根据需求设置参数,即可达到所需效果: 每轮需要答题数、满多少分可抽奖、是否提交选项后展示提示对错信息及答案、展示提示对错信息及答案的时长(毫秒)、是否需要计时(每轮正计时 / 每题答题限时倒计时 / 每轮答题限时倒计时)、倒计时开始时间(秒)。 注:每题答题限时倒计时 / 每轮答题限时倒计时,倒计时结束前用户有选择选项的,则自动提交当前选择答案,且对错计入最终分值。 excel表格格式如截图: 使用的图片资源: HTML: 答题 - 可配置每题倒计时自动答错 或 所有题答题结束总计时 *{ margin:0px; padding:0px; box-sizing:border-box; -webkit-tap-highlight-color:rgba(0,0,0,0); tap-highlight-color:rgba(0,0,0,0); cursor:pointer;} html{ max-width:750px; margin:0 auto;} body{ font-family:"PingFangSC-Regular","STHeitiSC-Light","微软雅黑","Microsoft YaHei","sans-serif"; font-size:28px; line-height:1.6; color: #666; -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; touch-callout:none; } li{ list-style:none;} [v-cloak]{ display: none;} .index{ height: 100vh; display: flex; justify-content: center; align-items: center;} .base_btn{ width: 420px; height: 80px; line-height: 80px; margin: 20px auto; text-align: center; color: #fff; border-radius: 40px; background-color: #FB3A1C;} /* 答题页 */ .question_body{ padding: 0 40px;} .question_number{ padding: 20px 0; text-align: center; font-size: 32px; font-weight: bold; position: relative;} .question_title{ max-height: 1000px; line-height: 44px;text-align: justify; word-wrap: break-word;} .question_options{ margin-top: 40px; padding-left: 20px;} .question_options li{ line-height: 42px; padding: 10px 20px 10px 60px; position: relative;} .question_options li:first-child ~ li{ margin-top: 30px;} /* 选中样式 */ .question_options li.cur{ color: #9a1500; font-weight: bold;} /* 选中时-正确样式 */ .question_options li.cur.right{ color: #17941A; font-weight: bold;} /* 选中时-错误样式 */ .question_options li.cur.wrong{ color: #E62225; font-weight: bold;} .question_options li span{ width: 46px; height: 46px; line-height: 44px; text-align: center; border-radius: 50%; border: #666 solid 1px; position: absolute; left: 0; top: 50%; margin-top: -23px;} /* 选中样式 */ .question_options li.cur span{ border: #9a1500 solid 1px;} /* 正确样式 */ .question_options li.right span{ font-size: 0; border-radius: 0; border: none; background: url(1.png) no-repeat center center; background-size: 100% 100%} /* 错误样式 */ .question_options li.wrong span{ font-size: 0; border-radius: 0; border: none; background: url(2.png) no-repeat center center; background-size: 100% 100%} /* 提示正确答案 */ .question_err{ margin: 20px 0; color: #E62225;} .question_err span{ font-weight: bold;} /* 计时显示 */ .question_time{ min-width: 170px; height: 50px; line-height: 45px; text-align: center; color: #fff; font-size: 24px; font-weight: bold; border-radius: 25px 0 0 25px; background-color: #1b855c; position: absolute; right: 0; top: 38px;} .question_time span{ margin: 0 5px; font-size: 30px;} /* 动画展示设置 */ .question.showanimation .question_body{ -webkit-animation: flipToMax .6s ease-out both; animation: flipToMax .6s ease-out both; } .question.showanimation .question_number{ -webkit-animation: flipToMax .6s .2s ease-out both; animation: flipToMax .6s .2s ease-out both; } .question.showanimation .question_title{ -webkit-animation: fadeToTop .6s .2s ease-out both; animation: fadeToTop .6s .2s ease-out both; } .question.showanimation .question_options li:nth-child(1){ -webkit-animation: fadeInMinToMax 1s .4s ease-out both; animation: fadeInMinToMax 1s .4s ease-out both; } .question.showanimation .question_options li:nth-child(2){ -webkit-animation: fadeInMinToMax 1s .6s ease-out both; animation: fadeInMinToMax 1s .6s ease-out both; } .question.showanimation .question_options li:nth-child(3){ -webkit-animation: fadeInMinToMax 1s .8s ease-out both; animation: fadeInMinToMax 1s .8s ease-out both; } .question.showanimation .question_options li:nth-child(4){ -webkit-animation: fadeInMinToMax 1s 1s ease-out both; animation: fadeInMinToMax 1s 1s ease-out both; } .question.showanimation .base_btn{ -webkit-animation: flipToMax .8s 1s ease-out both; animation: flipToMax .8s 1s ease-out both; } @-webkit-keyframes flipToMax{ 0%{ -webkit-transform:scale(0) scaleX(-1); opacity:0;} 100%{ -webkit-transform:scale(1) scaleX(1); opacity:1;} } @keyframes flipToMax{ 0%{ transform:scale(0) scaleX(-1); opacity:0;} 100%{ transform:scale(1) scaleX(1); opacity:1;} } @-webkit-keyframes fadeToTop{ 0%{ -webkit-transform:translateY(100%); opacity:0;} 100%{ -webkit-transform:translateY(0); opacity:1;} } @keyframes fadeToTop{ 0%{ transform:translateY(100%); opacity:0;} 100%{ transform:translateY(0); opacity:1;} } @-webkit-keyframes fadeInMinToMax{ 0%{ -webkit-transform:scale(0); opacity:0;} 100%{ -webkit-transform:scale(1); opacity:1;} } @keyframes fadeInMinToMax{ 0%{ transform:scale(0); opacity:0;} 100%{ transform:scale(1); opacity:1;} } /* 答题结束结果页 */ .pop{ width: 100%; height: 100%; background-color: rgba(0,0,0,.6); position: fixed; left: 0; top: 0; -webkit-animation: fadeIn .5s linear both; animation: fadeIn .5s linear both; } .pop_box{ width: 100%; height: 100%; padding-bottom: 80px; display: flex; justify-content: center; align-items: center; } .pop_body{ text-align: center; color: #fff; position: relative;} .pop_close{ width: 54px; position: absolute; left: 50%; margin-left: -27px; bottom: -85px;} 开始答题 {problemNumber}}题{{problem.tips}} --> {problemType}}题: -->{{problemNumber}}/{{problemAllNum}} {{problemType}}题: {{index}}{{item}} 正确答案:{{problem.right}} 下一题 确定提交 {{ifNeedTime == 1 ? '用时' : '倒计时'}}{{curTime}}s 用时{{curTime}}s 答对{{rightLen}}题,您的成绩 {{parseInt(rightLen * (100 / problemAllNum))}}分 达到可抽奖分数去抽奖 再来一次![]() 题库数据(Json格式): var questionJson = [ { "index": 1, "question": "1111当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目业的权利。", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", "D": "选项D", }, "right": "A,B,C" }, { "index": 2, "question": "2222当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", "D": "选项D", }, "right": "A,B,C,D" }, { "index": 3, "question": "3333当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", "D": "选项D", }, "right": "A,D" }, { "index": 4, "question": "4444当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", }, "right": "C" }, { "index": 5, "question": "5555当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", "D": "选项D", }, "right": "C" }, { "index": 6, "question": "6666当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", "D": "选项D", }, "right": "A,B,C,D" }, { "index": 7, "question": "7777当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", }, "right": "A" }, { "index": 8, "question": "8888当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", "D": "选项D", }, "right": "A,B,C,D" }, { "index": 9, "question": "9999当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", "D": "选项D", }, "right": "D" }, { "index": 10, "question": "10 10 10 当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", }, "right": "B" }, { "index": 11, "question": "11 11 11 当前题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目题目", "answer": { "A": "选项A", "B": "选项B", "C": "选项C", "D": "选项D", }, "right": "C" }, ]; |
CopyRight 2018-2019 实验室设备网 版权所有 |