بالطبع! إليك كود كويز علوم الطبيعة بلغة HTML مع CSS وJavaScript، مع خلفية زرقاء وأمواج متحركة وسحب متحركة من اليمين لليسار. عند الإجابة الصحيحة تظهر شمس متحركة مع كلمة "أحسنت"، وعند الخطأ تظهر عاصفة متحركة مع كلمة "إجابة خاطئة". الأزرار والكتابة جذابة.
يمكنك نسخ الكود التالي وتجربته مباشرة:
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<title>كويز علوم الطبيعة</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
font-family: 'Cairo', Arial, sans-serif;
background: #2196f3;
height: 100vh;
position: relative;
}
/* أمواج البحر */
.waves {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 200px;
z-index: 1;
overflow: hidden;
}
.wave {
position: absolute;
width: 200%;
height: 100%;
left: -50%;
background: rgba(255,255,255,0.2);
border-radius: 100% 50%;
animation: waveMove 8s linear infinite;
}
.wave2 {
top: 30px;
background: rgba(255,255,255,0.15);
animation-duration: 12s;
}
.wave3 {
top: 60px;
background: rgba(255,255,255,0.1);
animation-duration: 16s;
}
@keyframes waveMove {
0% { transform: translateX(0);}
100% { transform: translateX(50%);}
}
/* السحب */
.cloud {
position: absolute;
top: 40px;
width: 120px;
height: 60px;
background: #fff;
border-radius: 60px;
opacity: 0.8;
animation: cloudMove 30s linear infinite;
z-index: 2;
}
.cloud2 {
top: 90px;
left: 300px;
width: 90px;
height: 40px;
opacity: 0.7;
animation-duration: 40s;
}
.cloud3 {
top: 60px;
left: 600px;
width: 100px;
height: 50px;
opacity: 0.6;
animation-duration: 35s;
}
@keyframes cloudMove {
0% { right: -150px;}
100% { right: 110vw;}
}
/* محتوى الكويز */
.quiz-container {
position: relative;
z-index: 10;
background: rgba(255,255,255,0.85);
margin: 80px auto 0 auto;
padding: 30px 30px 40px 30px;
border-radius: 20px;
width: 350px;
box-shadow: 0 8px 32px rgba(0,0,0,0.2);
text-align: center;
}
.quiz-title {
font-size: 2em;
color: #1565c0;
margin-bottom: 20px;
font-weight: bold;
letter-spacing: 2px;
}
.question {
font-size: 1.3em;
color: #0d47a1;
margin-bottom: 25px;
font-weight: bold;
}
.options {
display: flex;
flex-direction: column;
gap: 15px;
}
.option-btn {
background: linear-gradient(90deg, #42a5f5 0%, #1976d2 100%);
color: #fff;
border: none;
border-radius: 12px;
padding: 12px 0;
font-size: 1.1em;
font-weight: bold;
cursor: pointer;
transition: background 0.3s, transform 0.2s;
box-shadow: 0 2px 8px rgba(33,150,243,0.15);
}
.option-btn:hover {
background: linear-gradient(90deg, #1976d2 0%, #42a5f5 100%);
transform: scale(1.04);
}
/* الرسائل */
.result {
margin-top: 25px;
font-size: 1.5em;
font-weight: bold;
display: flex;
flex-direction: column;
align-items: center;
min-height: 80px;
}
/* شمس متحركة */
.sun {
width: 60px;
height: 60px;
border-radius: 50%;
background: radial-gradient(circle at 30% 30%, #fffde7 60%, #ffeb3b 100%);
box-shadow: 0 0 40px 10px #fffde7, 0 0 80px 30px #ffeb3b;
margin-bottom: 10px;
animation: sunRise 1s ease;
position: relative;
}
@keyframes sunRise {
0% { transform: scale(0.2) translateY(40px); opacity: 0;}
100% { transform: scale(1) translateY(0); opacity: 1;}
}
/* أشعة الشمس */
.sun-ray {
position: absolute;
width: 6px;
height: 24px;
background: #fffde7;
left: 50%;
top: 50%;
transform-origin: bottom center;
border-radius: 3px;
opacity: 0.7;
animation: sunRayAnim 1.2s linear;
}
.sun-ray.r1 { transform: rotate(0deg) translate(-50%, -100%);}
.sun-ray.r2 { transform: rotate(45deg) translate(-50%, -100%);}
.sun-ray.r3 { transform: rotate(90deg) translate(-50%, -100%);}
.sun-ray.r4 { transform: rotate(135deg) translate(-50%, -100%);}
.sun-ray.r5 { transform: rotate(180deg) translate(-50%, -100%);}
.sun-ray.r6 { transform: rotate(225deg) translate(-50%, -100%);}
.sun-ray.r7 { transform: rotate(270deg) translate(-50%, -100%);}
.sun-ray.r8 { transform: rotate(315deg) translate(-50%, -100%);}
@keyframes sunRayAnim {
0% { opacity: 0; transform: scaleY(0.2);}
100% { opacity: 0.7; transform: scaleY(1);}
}
/* عاصفة متحركة */
.storm {
width: 60px;
height: 60px;
position: relative;
margin-bottom: 10px;
animation: stormAppear 1s;
}
@keyframes stormAppear {
0% { transform: scale(0.2) translateY(-40px); opacity: 0;}
100% { transform: scale(1) translateY(0); opacity: 1;}
}
.storm-cloud {
width: 60px;
height: 30px;
background: #b0bec5;
border-radius: 30px 30px 20px 20px;
position: absolute;
top: 10px;
left: 0;
box-shadow: 0 8px 20px #78909c;
}
.storm-lightning {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 25px solid #ffeb3b;
position: absolute;
left: 20px;
top: 35px;
animation: lightningFlash 0.5s infinite alternate;
}
@keyframes lightningFlash {
0% { opacity: 1;}
100% { opacity: 0.2;}
}
.storm-rain {
position: absolute;
left: 15px;
top: 50px;
width: 30px;
height: 20px;
display: flex;
justify-content: space-between;
}
.rain-drop {
width: 4px;
height: 16px;
background: #2196f3;
border-radius: 50%;
opacity: 0.7;
animation: rainDrop 0.7s infinite linear;
}
.rain-drop:nth-child(2) { animation-delay: 0.2s;}
.rain-drop:nth-child(3) { animation-delay: 0.4s;}
@keyframes rainDrop {
0% { transform: translateY(0);}
100% { transform: translateY(10px);}
}
/* زر التالي */
.next-btn {
margin-top: 20px;
background: linear-gradient(90deg, #00c853 0%, #43a047 100%);
color: #fff;
border: none;
border-radius: 12px;
padding: 12px 0;
font-size: 1.1em;
font-weight: bold;
cursor: pointer;
width: 100%;
transition: background 0.3s, transform 0.2s;
box-shadow: 0 2px 8px rgba(76,175,80,0.15);
display: none;
}
.next-btn.show {
display: block;
animation: btnAppear 0.5s;
}
@keyframes btnAppear {
0% { opacity: 0; transform: scale(0.8);}
100% { opacity: 1; transform: scale(1);}
}
</style>
</head>
<body>
<!-- السحب -->
<div class="cloud" style="right: 0;"></div>
<div class="cloud cloud2"></div>
<div class="cloud cloud3"></div>
<!-- أمواج البحر -->
<div class="waves">
<div class="wave"></div>
<div class="wave wave2"></div>
<div class="wave wave3"></div>
</div>
<!-- محتوى الكويز -->
<div class="quiz-container">
<div class="quiz-title">كويز علوم الطبيعة</div>
<div class="question" id="question"></div>
<div class="options" id="options"></div>
<div class="result" id="result"></div>
<button class="next-btn" id="nextBtn">التالي</button>
</div>
<script>
// أسئلة الكويز
const quizData = [
{
question: "ما هو الكوكب الأقرب إلى الشمس؟",
options: ["الأرض", "عطارد", "المريخ", "الزهرة"],
answer: 1
},
{
question: "ما هو العنصر الأكثر وفرة في الكون؟",
options: ["الأكسجين", "الهيدروجين", "الكربون", "النيتروجين"],
answer: 1
},
{
question: "ما هو الحيوان الذي يُلقب بسيد الغابة؟",
options: ["النمر", "الأسد", "الفيل", "الدب"],
answer: 1
},
{
question: "ما هو العضو المسؤول عن ضخ الدم في جسم الإنسان؟",
options: ["الكبد", "الرئة", "القلب", "الكلى"],
answer: 2
}
];
let currentQuestion = 0;
let allowAnswer = true;
function showQuestion() {
allowAnswer = true;
document.getElementById('result').innerHTML = '';
document.getElementById('nextBtn').classList.remove('show');
const q = quizData[currentQuestion];
document.getElementById('question').textContent = q.question;
const optionsDiv = document.getElementById('options');
optionsDiv.innerHTML = '';
q.options.forEach((opt, idx) => {
const btn = document.createElement('button');
btn.className = 'option-btn';
btn.textContent = opt;
btn.onclick = () => checkAnswer(idx);
optionsDiv.appendChild(btn);
});
}
function checkAnswer(selected) {
if (!allowAnswer) return;
allowAnswer = false;
const q = quizData[currentQuestion];
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = '';
if (selected === q.answer) {
// شمس متحركة + أحسنت
resultDiv.innerHTML = `
<div class="sun">
<div class="sun-ray r1"></div>
<div class="sun-ray r2"></div>
<div class="sun-ray r3"></div>
<div class="sun-ray r4"></div>
<div class="sun-ray r5"></div>
<div class="sun-ray r6"></div>
<div class="sun-ray r7"></div>
<div class="sun-ray r8"></div>
</div>
<span style="color:#fbc02d; font-size:1.3em; margin-top:8px;">☀️ أحسنت!</span>
`;
} else {
// عاصفة متحركة + إجابة خاطئة
resultDiv.innerHTML = `
<div class="storm">
<div class="storm-cloud"></div>
<div class="storm-lightning"></div>
<div class="storm-rain">
<div class="rain-drop"></div>
<div class="rain-drop"></div>
<div class="rain-drop"></div>
</div>
</div>
<span style="color:#1976d2; font-size:1.2em; margin-top:8px;">⛈️ إجابة خاطئة!</span>
`;
}
document.getElementById('nextBtn').classList.add('show');
}
document.getElementById('nextBtn').onclick = function() {
currentQuestion++;
if (currentQuestion < quizData.length) {
showQuestion();
} else {
document.querySelector('.quiz-container').innerHTML = `
<div class="quiz-title">انتهى الكويز!</div>
<div style="font-size:1.3em; color:#1565c0; margin-top:30px;">شكراً لمشاركتك 🌊</div>
`;
}
};
// بدء الكويز
showQuestion();
</script>
</body>
</html>
ملاحظات:
- الكود متكامل ويعمل مباشرة في أي متصفح حديث.
- يمكنك تعديل الأسئلة أو الألوان أو إضافة المزيد من المؤثرات حسب رغبتك.
- تم استخدام CSS فقط للأنيميشن والمؤثرات البصرية بدون أي مكتبات خارجية.
إذا أردت إضافة المزيد من الأسئلة أو تحسينات أخرى، أخبرني بذلك! 🌊