Spaces:
Running
Running
Upload 3 files
Browse files- index.html +25 -19
- script.js +24 -0
- styles.css +45 -0
index.html
CHANGED
|
@@ -1,19 +1,25 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fr">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Exercices de Maths</title>
|
| 7 |
+
<link rel="stylesheet" href="styles.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div class="container">
|
| 11 |
+
<h1>Exercices de Maths</h1>
|
| 12 |
+
<p>Bienvenue sur notre site d'exercices de maths pour les élèves de 12 ans.</p>
|
| 13 |
+
|
| 14 |
+
<div class="exercise">
|
| 15 |
+
<h2>Exercice de Multiplication</h2>
|
| 16 |
+
<p id="question">Quelle est la réponse à cette multiplication : <span id="num1">2</span> x <span id="num2">3</span> ?</p>
|
| 17 |
+
<input type="number" id="answer" placeholder="Votre réponse">
|
| 18 |
+
<button onclick="checkAnswer()">Vérifier</button>
|
| 19 |
+
<p id="feedback"></p>
|
| 20 |
+
</div>
|
| 21 |
+
</div>
|
| 22 |
+
|
| 23 |
+
<script src="script.js"></script>
|
| 24 |
+
</body>
|
| 25 |
+
</html>
|
script.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function generateQuestion() {
|
| 2 |
+
const num1 = Math.floor(Math.random() * 10) + 1;
|
| 3 |
+
const num2 = Math.floor(Math.random() * 10) + 1;
|
| 4 |
+
document.getElementById('num1').textContent = num1;
|
| 5 |
+
document.getElementById('num2').textContent = num2;
|
| 6 |
+
return num1 * num2;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
let correctAnswer = generateQuestion();
|
| 10 |
+
|
| 11 |
+
function checkAnswer() {
|
| 12 |
+
const userAnswer = parseInt(document.getElementById('answer').value);
|
| 13 |
+
const feedback = document.getElementById('feedback');
|
| 14 |
+
|
| 15 |
+
if (userAnswer === correctAnswer) {
|
| 16 |
+
feedback.textContent = "Bonne réponse !";
|
| 17 |
+
feedback.style.color = "green";
|
| 18 |
+
correctAnswer = generateQuestion();
|
| 19 |
+
document.getElementById('answer').value = '';
|
| 20 |
+
} else {
|
| 21 |
+
feedback.textContent = "Mauvaise réponse, essaye encore !";
|
| 22 |
+
feedback.style.color = "red";
|
| 23 |
+
}
|
| 24 |
+
}
|
styles.css
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body {
|
| 2 |
+
font-family: Arial, sans-serif;
|
| 3 |
+
background-color: #f4f4f9;
|
| 4 |
+
margin: 0;
|
| 5 |
+
padding: 0;
|
| 6 |
+
display: flex;
|
| 7 |
+
justify-content: center;
|
| 8 |
+
align-items: center;
|
| 9 |
+
height: 100vh;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
.container {
|
| 13 |
+
background-color: #fff;
|
| 14 |
+
padding: 20px;
|
| 15 |
+
border-radius: 8px;
|
| 16 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
| 17 |
+
text-align: center;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
h1 {
|
| 21 |
+
color: #333;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.exercise {
|
| 25 |
+
margin-top: 20px;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
input[type="number"] {
|
| 29 |
+
padding: 8px;
|
| 30 |
+
margin: 10px 0;
|
| 31 |
+
width: 100px;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
button {
|
| 35 |
+
padding: 8px 16px;
|
| 36 |
+
background-color: #007BFF;
|
| 37 |
+
color: #fff;
|
| 38 |
+
border: none;
|
| 39 |
+
border-radius: 4px;
|
| 40 |
+
cursor: pointer;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
button:hover {
|
| 44 |
+
background-color: #0056b3;
|
| 45 |
+
}
|