سأقوم بإنشاء كويز تفاعلي عن علوم الطبيعة بالمواصفات التي طلبتها. إليك الكود الكامل:
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>كويز علوم الطبيعة</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Tajawal', sans-serif;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(to bottom, #87CEEB 0%, #4682B4 100%);
overflow: hidden;
position: relative;
}
/* خلفية الأمواج */
.waves {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 200px;
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120" preserveAspectRatio="none"><path d="M321.39,56.44c58-10.79,114.16-30.13,172-41.86,82.39-16.72,168.19-17.73,250.45-.39C823.78,31,906.67,72,985.66,92.83c70.05,18.48,146.53,26.09,214.34,3V0H0V27.35A600.21,600.21,0,0,0,321.39,56.44Z" fill="%231E90FF" opacity="0.3"></path></svg>') repeat-x;
animation: waves 20s linear infinite;
}
.waves::before {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 200px;
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120" preserveAspectRatio="none"><path d="M321.39,56.44c58-10.79,114.16-30.13,172-41.86,82.39-16.72,168.19-17.73,250.45-.39C823.78,31,906.67,72,985.66,92.83c70.05,18.48,146.53,26.09,214.34,3V0H0V27.35A600.21,600.21,0,0,0,321.39,56.44Z" fill="%234169E1" opacity="0.5"></path></svg>') repeat-x;
animation: waves 15s linear infinite;
}
@keyframes waves {
0% { background-position-x: 0; }
100% { background-position-x: 1200px; }
}
/* السحب المتحركة */
.cloud {
position: absolute;
background: white;
border-radius: 100px;
opacity: 0.7;
}
.cloud::before {
content: '';
position: absolute;
background: white;
border-radius: 100px;
}
.cloud1 {
width: 100px;
height: 40px;
top: 20%;
animation: float 30s infinite;
}
.cloud1::before {
width: 50px;
height: 50px;
top: -25px;
left: 10px;
}
.cloud2 {
width: 80px;
height: 35px;
top: 40%;
animation: float 35s infinite;
}
.cloud2::before {
width: 60px;
height: 40px;
top: -20px;
right: 15px;
}
@keyframes float {
from { right: -200px; }
to { right: 100%; }
}
/* حاوية الكويز */
.quiz-container {
background: rgba(255, 255, 255, 0.95);
padding: 40px;
border-radius: 20px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
max-width: 600px;
width: 90%;
position: relative;
z-index: 10;
}
h1 {
text-align: center;
color: #2c3e50;
margin-bottom: 30px;
font-size: 2.5em;
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}
.question {
font-size: 1.3em;
color: #34495e;
margin-bottom: 20px;
text-align: center;
}
.options {
display: grid;
gap: 15px;
margin-bottom: 30px;
}
.option {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 15px 25px;
border-radius: 50px;
font-size: 1.1em;
cursor: pointer;
transition: all 0.3s ease;
font-weight: bold;
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.option:hover {
transform: translateY(-3px);
box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.option:active {
transform: translateY(-1px);
}
/* الشمس */
.sun {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 100px;
display: none;
animation: sunAppear 2s ease-out;
z-index: 100;
}
@keyframes sunAppear {
0% {
transform: translate(-50%, -50%) scale(0) rotate(0deg);
opacity: 0;
}
50% {
transform: translate(-50%, -50%) scale(1.2) rotate(180deg);
opacity: 1;
}
100% {
transform: translate(-50%, -50%) scale(1) rotate(360deg);
opacity: 1;
}
}
/* العاصفة */
.storm {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 100px;
display: none;
animation: stormAppear 2s ease-out;
z-index: 100;
}
@keyframes stormAppear {
0% {
transform: translate(-50%, -50%) scale(0);
opacity: 0;
}
25% {
transform: translate(-50%, -60%) scale(1.1);
}
50% {
transform: translate(-50%, -40%) scale(1.1);
}
75% {
transform: translate(-50%, -60%) scale(1.1);
}
100% {
transform: translate(-50%, -50%) scale(1);
opacity: 1;
}
}
/* رسالة النتيجة */
.result-message {
position: fixed;
top: 60%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 2em;
font-weight: bold;
display: none;
animation: messageAppear 1s ease-out;
z-index: 100;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.correct-message {
color: #f39c12;
}
.wrong-message {
color: #e74c3c;
}
@keyframes messageAppear {
0% {
opacity: 0;
transform: translate(-50%, -30%) scale(0.5);
}
100% {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
}
.score {
text-align: center;
font-size: 1.2em;
color: #2c3e50;
margin-bottom: 20px;
}
.next-btn {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
color: white;
border: none;
padding: 12px 30px;
border-radius: 50px;
font-size: 1.1em;
cursor: pointer;
display: none;
margin: 0 auto;
font-weight: bold;
transition: all 0.3s ease;
}
.next-btn:hover {
transform: scale(1.05);
}
</style>
</head>
<body>
<!-- السحب المتحركة -->
<div class="cloud cloud1"></div>
<div class="cloud cloud2"></div>
<!-- الأمواج -->
<div class="waves"></div>
<!-- حاوية الكويز -->
<div class="quiz-container">
<h1>🌿 كويز علوم الطبيعة 🌿</h1>
<div class="score">النقاط: <span id="score">0</span> / <span id="total">0</span></div>
<div id="question-container">
<p class="question" id="question"></p>
<div class="options" id="options"></div>
</div>
<button class="next-btn" id="next-btn" onclick="nextQuestion()">السؤال التالي</button>
</div>
<!-- الشمس والعاصفة -->
<div class="sun" id="sun">☀️</div>
<div class="storm" id="storm">⛈️</div>
<div class="result-message correct-message" id="correct-message">أحسنت! 🎉</div>
<div class="result-message wrong-message" id="wrong-message">حاول مرة أخرى 💪</div>
<script>
const questions = [
{
question: "ما هو أكبر كوكب في المجموعة الشمسية؟",
options: ["الأرض", "المريخ", "المشتري", "زحل"],
correct: 2
},
{
question: "ما هي عملية تحويل الماء من الحالة السائلة إلى الغازية؟",
options: ["التكثف", "التبخر", "التجمد", "الانصهار"],
correct: 1
},
{
question: "ما هو العضو المسؤول عن ضخ الدم في جسم الإنسان؟",
options: ["الكبد", "الرئتان", "القلب", "الكلى"],
correct: 2
},
{
question: "كم عدد أرجل العنكبوت؟",
options: ["6", "8", "10", "12"],
correct: 1
},
{
question: "ما هي وحدة قياس القوة؟",
options: ["الجول", "النيوتن", "الواط", "الأمبير"],
correct: 1
}
];
let currentQuestion = 0;
let score = 0;
let answered = false;
function loadQuestion() {
answered = false;
document.getElementById('next-btn').style.display = 'none';
const q = questions[currentQuestion];
document.getElementById('question').textContent = q.question;
const optionsContainer = document.getElementById('options');
optionsContainer.innerHTML = '';
q.options.forEach((option, index) => {
const button = document.createElement('button');
button.className = 'option';
button.textContent = option;
button.onclick = () => checkAnswer(index);
optionsContainer.appendChild(button);
});
document.getElementById('total').textContent = currentQuestion + 1;
}
function checkAnswer(selected) {
if (answered) return;
answered = true;
const correct = questions[currentQuestion].correct;
const options = document.querySelectorAll('.option');
if (selected === correct) {
score++;
document.getElementById('score').textContent = score;
showResult(true);
options[selected].style.background = 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)';
} else {
showResult(false);
options[selected].style.background = 'linear-gradient(135deg, #eb3349 0%, #f45c43 100%)';
options[correct].style.background = 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)';
}
options.forEach(option => {
option.style.cursor = 'not-allowed';
option.onclick = null;
});
setTimeout(() => {
document.getElementById('next-btn').style.display = 'block';
}, 2000);
}
function showResult(isCorrect) {
if (isCorrect) {
document.getElementById('sun').style.display = 'block';
document.getElementById('correct-message').style.display = 'block';
setTimeout(() => {
document.getElementById('sun').style.display = 'none';
document.getElementById('correct-message').style.display = 'none';
}, 2000);
} else {
document.getElementById('storm').style.display = 'block';
document.getElementById('wrong-message').style.display = 'block';
setTimeout(() => {
document.getElementById('storm').style.display = 'none';
document.getElementById('wrong-message').style.display = 'none';
}, 2000);
}
}
function nextQuestion() {
currentQuestion++;
if (currentQuestion < questions.length) {
loadQuestion();
} else {
showFinalScore();
}
}
function showFinalScore() {
const container = document.getElementById('question-container');
container.innerHTML = `
<h2 style="text-align: center; color: #2c3e50; margin-bottom: 20px;">ان