Driver's Test
by guydog28
HTML
<script src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
<div id="root"></div>
CSS
.quiz-container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #f9f9f9;
}
.score-section {
margin-bottom: 20px;
}
.score-section span {
padding: 5px;
}
.score-section .correct{
color: green;
}
.score-section .incorrect{
color: red;
}
.score-section .incomplete{
color: gray;
}
.question-answer-container {
min-height: 460px; /* Set minimum height for question and answer container */
}
.question-section {
display: flex;
align-items: left;
margin-bottom: 20px;
justify-content: space-between;
}
.image-container {
display: flex;
justify-content: center; /* Adjust if you want to align images differently */
flex-wrap: wrap;
gap: 10px; /* Adjust the gap as needed */
margin-bottom: 20px; /* Space between images and question text */
}
.quiz-image {
max-width: 50px; /* Adjust based on your needs, make sure it's small enough to allow wrapping */
height: auto;
border: 1px solid #ddd; /* Optional border */
box-shadow: 2px 2px 5px rgba(0,0,0,0.2); /* Optional shadow */
}
.question-text {
font-size: 1.2em; /* Increased font size */
font-weight: bold; /* Make text bold */
margin-top: 20px;
}
.retry-text {
font-size: 0.8em;
font-style: italic;
margin-left: 10px;
color: #ff0000; /* Red color for emphasis */
}
.answer-section button {
display: block;
width: 100%;
padding: 14px;
margin-bottom: 14px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #fff;
color: black;
text-align: left;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
.answer-section button.correct {
background-color: #d4edda;
color: #155724;
}
.answer-section button.incorrect {
background-color: #f8d7da;
color: #721c24;
}
.navigation-section {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.other-section {
display: flex;
justify-content: space-between;
margin-top:...
Babel + JSX
const { useState, useEffect } = React;
const questionsData = [
{
"question": "",
"options": {
"A": "A stop sign, indicating that vehicles must come to a complete stop.",
"B": "A yield sign, advising vehicles to slow down and be prepared to stop if necessary.",
"C": "A pedestrian crossing sign, indicating where pedestrians may be crossing.",
"D": "A no entry sign, indicating no entry to all vehicles."
},
"answer": "A",
"selected": null,
"imageSrc": [
...