يمكنني إنشاء موقع بسيط يحتوي على جدول الضرب من 1 إلى 10 بطريقة مميزة ومسلية. إليك كود HTML بسيط:
<!DOCTYPE html>
<html dir="rtl">
<head>
<meta charset="UTF-8">
<title>جدول الضرب المرح</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f0f8ff;
text-align: center;
}
h1 {
color: #4b0082;
margin-top: 20px;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 15px;
margin: 20px;
}
.table-card {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
padding: 15px;
width: 200px;
transition: transform 0.3s, box-shadow 0.3s;
}
.table-card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
background-color: #fffacd;
}
.table-title {
font-size: 20px;
color: #ff6347;
margin-bottom: 10px;
}
.table-row {
padding: 5px;
border-bottom: 1px dashed #ddd;
}
.table-row:hover {
background-color: #e6f7ff;
font-weight: bold;
}
.game-section {
margin: 30px auto;
max-width: 600px;
background-color: #e6ffe6;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
button {
background-color: #4caf50;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
margin: 10px;
}
button:hover {
background-color: #45a049;
}
input {
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ddd;
text-align: center;
}
.result {
font-size: 18px;
margin: 10px;
font-weight: bold;
}
.correct {
color: green;
}
.incorrect {
color: red;
}
</style>
</head>
<body>
<h1>جدول الضرب المرح</h1>
<div class="container">
<!-- سيتم إنشاء بطاقات جداول الضرب هنا بواسطة JavaScript -->
</div>
<div class="game-section">
<h2>اختبر معلوماتك!</h2>
<p>أجب على سؤال عشوائي من جدول الضرب:</p>
<div id="question">جاهز للبدء؟</div>
<input type="number" id="answer" placeholder="أدخل الإجابة">
<button id="check">تحقق</button>
<button id="new-question">سؤال جديد</button>
<div id="result" class="result"></div>
</div>
<script>
// إنشاء بطاقات جداول الضرب
const container = document.querySelector('.container');
for (let i = 1; i <= 10; i++) {
const tableCard = document.createElement('div');
tableCard.className = 'table-card';
const tableTitle = document.createElement('div');
tableTitle.className = 'table-title';
tableTitle.textContent = `جدول الضرب ${i}`;
tableCard.appendChild(tableTitle);
for (let j = 1; j <= 10; j++) {
const tableRow = document.createElement('div');
tableRow.className = 'table-row';
tableRow.textContent = `${i} × ${j} = ${i * j}`;
tableCard.appendChild(tableRow);
}
container.appendChild(tableCard);
}
// وظائف اللعبة
let currentNum1, currentNum2;
function generateQuestion() {
currentNum1 = Math.floor(Math.random() * 10) + 1;
currentNum2 = Math.floor(Math.random() * 10) + 1;
document.getElementById('question').textContent = `كم ناتج ${currentNum1} × ${currentNum2}؟`;
document.getElementById('answer').value = '';
document.getElementById('result').textContent = '';
}
document.getElementById('new-question').addEventListener('click', generateQuestion);
document.getElementById('check').addEventListener('click', function() {
const userAnswer = parseInt(document.getElementById('answer').value);
const correctAnswer = currentNum1 * currentNum2;
const resultElement = document.getElementById('result');
if (userAnswer === correctAnswer) {
resultElement.textContent = 'إجابة صحيحة! أحسنت!';
resultElement.className = 'result correct';
// إضافة تأثير للبطاقة المناسبة
highlightCard(currentNum1);
} else {
resultElement.textContent = `إجابة خاطئة. الإجابة الصحيحة هي ${correctAnswer}`;
resultElement.className = 'result incorrect';
}
});
function highlightCard(number) {
const cards = document.querySelectorAll('.table-card');
cards[number-1].style.backgroundColor = '#caffca';
setTimeout(() => {
cards[number-1].style.backgroundColor = '';
}, 1000);
}
// بدء اللعبة بسؤال عند تحميل الصفحة
window.onload = generateQuestion;
</script>
</body>
</html>
هل تريد مني شرح أو تفصيل هذا الكود؟