<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>جلسه پنجم - CSS</title>
<style>
/* استایل کلی صفحه */
body {
background-color: #f4f4f4;
font-family: Tahoma, sans-serif;
margin: 0;
padding: 20px;
}
/* استایل کارت */
.card {
background-color: white;
width: 300px;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
margin: 20px auto; /* وسط چین کردن */
}
.card h2 {
color: #2c3e50;
margin-top: 0;
}
.card p {
color: #666;
line-height: 1.6;
}
.btn {
background-color: #3498db;
color: white;
padding: 10px 15px;
text-decoration: none;
border-radius: 5px;
display: inline-block;
}
</style>
</head>
<body>
<div class="card">
<h2>🎨 معرفی CSS</h2>
<p>
CSS به ما کمک میکنه تا وبسایتهای زیبا و جذاب بسازیم.
با استفاده از CSS میتونیم رنگ، فونت و اندازه رو کنترل کنیم.
</p>
<a href="#" class="btn">بیشتر بخوانید</a>
</div>
</body>
</html>
کد نهایی جلسه پنجم برای تمرین
eitaa.com/Pythonfriend
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<title>جلسه هفتم - شرطها</title>
<style>
body { font-family: Tahoma; padding: 20px; background: #f9f9f9; }
.result {
margin-top: 20px;
padding: 15px;
background: #fff;
border: 1px solid #ddd;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>🧠 تست شرطها</h1>
<p>کدها در کنسول مرورگر (F12) اجرا میشوند.</p>
<div class="result" id="output">نتیجه اینجا نمایش داده میشود...</div>
<script>
// مثال ۱: ساده
let score = 15;
if (score >= 10) {
console.log("شما قبول شدید!");
document.getElementById("output").innerHTML = "✅ قبول شدید";
} else {
console.log("متاسفانه مردود شدید.");
document.getElementById("output").innerHTML = "❌ مردود شدید";
}
// مثال ۲: شرط منطقی
let username = "admin";
let password = "123";
if (username === "admin" && password === "123") {
console.log("ورود موفق!");
} else {
console.log("نام کاربری یا رمز عبور اشتباه است.");
}
</script>
</body>
</html>
کد نهایی جلسه هفتم برای تمرین
eitaa.com/Pythonfriend
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<title>جلسه یازدهم - رویدادها</title>
<style>
body { font-family: Tahoma; padding: 20px; text-align: center; }
.container { margin-top: 50px; }
button {
padding: 10px 20px;
font-size: 18px;
margin: 10px;
cursor: pointer;
}
#counter {
font-size: 40px;
font-weight: bold;
color: #333;
}
.box {
width: 200px;
height: 100px;
background: #ddd;
margin: 20px auto;
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
transition: all 0.3s;
}
</style>
</head>
<body>
<div class="container">
<h1>🖱️ تست رویدادها</h1>
<!-- شمارنده -->
<div id="counter">0</div>
<button id="incrementBtn">افزایش (+1)</button>
<button id="resetBtn">ریست (0)</button>
<hr>
<!-- باکس هاور -->
<div class="box" id="hoverBox">موس رو بیار روش!</div>
</div>
<script>
// ۱. رویداد شمارنده
let count = 0;
let counterDisplay = document.getElementById("counter");
let incBtn = document.getElementById("incrementBtn");
let resetBtn = document.getElementById("resetBtn");
incBtn.addEventListener("click", function() {
count++;
counterDisplay.textContent = count;
// تغییر رنگ بر اساس عدد
if (count > 10) {
counterDisplay.style.color = "red";
} else {
counterDisplay.style.color = "#333";
}
});
resetBtn.addEventListener("click", function() {
count = 0;
counterDisplay.textContent = count;
counterDisplay.style.color = "#333";
});
// ۲. رویداد هاور (Mouse Over/Out)
let box = document.getElementById("hoverBox");
box.addEventListener("mouseover", function() {
box.style.backgroundColor = "#4CAF50";
box.style.color = "white";
box.style.transform = "scale(1.1)"; // بزرگ شدن کمی
});
box.addEventListener("mouseout", function() {
box.style.backgroundColor = "#ddd";
box.style.color = "#333";
box.style.transform = "scale(1)";
});
// ۳. رویداد کلیک روی کل صفحه
document.addEventListener("click", function(e) {
console.log("کلیک در صفحه: " + e.target.tagName);
});
</script>
</body>
</html>
کد نهایی جلسه یازدهم برای تمرین
eitaa.com/Pythonfriend