-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1647 from KapuluruBhuvaneswariVspdbct/k
solved #1637 Added (easy ,diff,med)css challenges
- Loading branch information
Showing
4 changed files
with
773 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>CSS EASY Quiz</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #08114c; | ||
margin: 0; | ||
padding: 20px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
|
||
.quiz-container { | ||
background-color: white; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); | ||
max-width: 600px; | ||
width: 100%; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.question { | ||
margin-bottom: 15px; | ||
} | ||
|
||
.options { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
.option { | ||
background-color: #e7f3fe; | ||
padding: 10px; | ||
border-radius: 5px; | ||
margin: 5px 0; | ||
cursor: pointer; | ||
transition: background-color 0.3s; | ||
border: 2px solid transparent; /* Default border */ | ||
} | ||
|
||
.option:hover { | ||
background-color: #d1e7fd; | ||
} | ||
|
||
.selected { | ||
background-color: #b3e5fc; | ||
border: 2px solid #007bff; /* Selected border color */ | ||
} | ||
|
||
button { | ||
background-color: #007bff; | ||
color: white; | ||
border: none; | ||
padding: 10px; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
display: block; | ||
width: 100%; | ||
margin-top: 10px; | ||
} | ||
|
||
button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
.hidden { | ||
display: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="quiz-container"> | ||
<h1>CSS EASY CHALLENGE</h1> | ||
<div id="question-container"></div> | ||
<button id="next-button" class="hidden" onclick="nextQuestion()">Next Question</button> | ||
<button id="submit-button" class="hidden" onclick="submitAnswers()">Submit Answers</button> | ||
</div> | ||
|
||
<script> | ||
const questions = [ | ||
{ | ||
question: "1) What is CSS?", | ||
options: [ | ||
"CSS is a style sheet language", | ||
"CSS is designed to separate the presentation and content, including layout, colors, and fonts", | ||
"CSS is the language used to style the HTML documents", | ||
"All of the mentioned" | ||
], | ||
answer: 3 | ||
}, | ||
{ | ||
question: "2) Which of the following tag is used to embed CSS in an HTML page?", | ||
options: [ | ||
"<css>", | ||
"<!DOCTYPE html>", | ||
"<script>", | ||
"<style>" | ||
], | ||
answer: 3 | ||
}, | ||
{ | ||
question: "3) Which of the following CSS selectors are used to specify a group of elements?", | ||
options: [ | ||
"tag", | ||
"id", | ||
"class", | ||
"both class and tag" | ||
], | ||
answer: 3 | ||
}, | ||
{ | ||
question: "4) Which of the following has introduced text, list, box, margin, border, color, and background properties?", | ||
options: [ | ||
"HTML", | ||
"PHP", | ||
"CSS", | ||
"Ajax" | ||
], | ||
answer: 2 | ||
}, | ||
{ | ||
question: "5) Which of the following CSS framework is used to create a responsive design?", | ||
options: [ | ||
"django", | ||
"rails", | ||
"larawell", | ||
"bootstrap" | ||
], | ||
answer: 3 | ||
}, | ||
{ | ||
question: "6) Which of the following CSS selector is used to specify a rule to bind a particular unique element?", | ||
options: [ | ||
"tag", | ||
"id", | ||
"class", | ||
"both class and tag" | ||
], | ||
answer: 1 | ||
}, | ||
{ | ||
question: "7) Which of the following type of HTML tag is used to define an internal style sheet?", | ||
options: [ | ||
"<script>", | ||
"<link>", | ||
"<class>", | ||
"<style>" | ||
], | ||
answer: 3 | ||
}, | ||
{ | ||
question: "8) Which of the following CSS property is used to make the text bold?", | ||
options: [ | ||
"text-decoration: bold", | ||
"font-weight: bold", | ||
"font-style: bold", | ||
"text-align: bold" | ||
], | ||
answer: 1 | ||
}, | ||
{ | ||
question: "9) What will be the output of the following CSS code snippet? <h1> {color: 'green';}", | ||
options: [ | ||
"nothing happens", | ||
"error occurs", | ||
"heading becomes dark-green", | ||
"heading becomes green" | ||
], | ||
answer: 3 | ||
}, | ||
{ | ||
question: "10) Which of the following CSS style property is used to specify italic text?", | ||
options: [ | ||
"style", | ||
"font", | ||
"font-style", | ||
"@font-face" | ||
], | ||
answer: 2 | ||
} | ||
]; | ||
|
||
let currentQuestionIndex = 0; | ||
let score = 0; | ||
|
||
function showQuestion() { | ||
const questionContainer = document.getElementById('question-container'); | ||
const question = questions[currentQuestionIndex]; | ||
questionContainer.innerHTML = ` | ||
<div class="question"> | ||
<h3>${question.question}</h3> | ||
<ul class="options"> | ||
${question.options.map((option, i) => ` | ||
<li class="option" onclick="selectOption(this, ${i})">${option}</li> | ||
`).join('')} | ||
</ul> | ||
</div> | ||
`; | ||
document.getElementById('next-button').classList.add('hidden'); | ||
document.getElementById('submit-button').classList.add('hidden'); | ||
} | ||
|
||
function selectOption(optionElement, selectedIndex) { | ||
const options = document.querySelectorAll('.option'); | ||
options.forEach(option => option.classList.remove('selected')); | ||
optionElement.classList.add('selected'); | ||
|
||
const question = questions[currentQuestionIndex]; | ||
if (selectedIndex === question.answer) { | ||
score++; | ||
} | ||
|
||
document.getElementById('next-button').classList.remove('hidden'); | ||
} | ||
|
||
function nextQuestion() { | ||
currentQuestionIndex++; | ||
if (currentQuestionIndex < questions.length) { | ||
showQuestion(); | ||
} else { | ||
document.getElementById('next-button').classList.add('hidden'); | ||
document.getElementById('submit-button').classList.remove('hidden'); | ||
document.getElementById('question-container').innerHTML = `<h3>Challenge Complete! Your score is ${score} out of ${questions.length}</h3>`; | ||
} | ||
} | ||
|
||
function submitAnswers() { | ||
alert(`You scored ${score} out of ${questions.length}`); | ||
window.location.href = 'index.html'; // Redirect to main page after submitting | ||
} | ||
|
||
window.onload = showQuestion; // Show the first question when the page loads | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.