TGViewer
Channel Public Channel
Html and Css & Jsآموزش

Html and Css & Jsآموزش

@htmlcss_channels

ادمین :
@Maryam3771


تعرفه تبلیغات:
https://t.me/alloadv/822
Subscribers
23.1K
Photos
579
Videos
278
Links
361

Showing posts older than #2465 · Back to latest

Older Posts 5 shown
Post #2462 1.58K
؛CSS Houdini چیست؟
یه API قدرتمند که بهت اجازه می‌ده مستقیماً با CSS نقاشی بکشی! 🎨

۵ مرحله‌ای که تصاویر نشون می‌دن:
۱️⃣ ساخت Paint Worklet
class DotsPainter {
paint(ctx, geom, props) {
ctx.fillStyle = 'pink';
for (let y = 0; y < geom.height; y += 20) {
for (let x = 0; x < geom.width; x += 20) {
ctx.beginPath();
ctx.arc(x, y, 5, 0, 2 * Math.PI);
ctx.fill();
}
}
}
}
registerPaint('dots', DotsPainter)

یه کلاس جاوااسکریپت می‌نویسی که روی canvas رسم می‌کنه.

۲️⃣ ثبت Worklet
CSS.paintWorklet.addModule('paint.js');

فایل جاوااسکریپت رو به مرورگر معرفی می‌کنی.

۳️⃣ استفاده در CSS
.box {
background: paint(dots);
}

حالا می‌تونی مثل background معمولی استفاده کنی!

۴️⃣ شخصی‌سازی با متغیرها
ctx.fillStyle = props.get('--dot-color') || 'pink';



.box {
background: paint(dots);
--dot-color: blue;
}

رنگ رو از CSS تغییر بده!

۵️⃣ نتیجه
• ✅ بدون عکس
• ✅ بدون پلاگین
• ✅ فقط CSS خالص
• ✅ روی compositor thread اجرا می‌شه (سریع)



💎 @Htmlcss_channels | #HTML #css #JavaScript
  • ❤ 5
Post #2454 1.24K
؛CSS Houdini چیست؟
یه API قدرتمند که بهت اجازه می‌ده مستقیماً با CSS نقاشی بکشی! 🎨

توضیحات بیشتر و کدهارو در پست بعدی ببینید👇👇


💎 @Htmlcss_channels | #HTML #css #JavaScript
  • 🔥 2
  • ❤ 1
Post #2446 1.4K
✨ مجموعه‌ای از کدهای کوتاه ولی کاربردی CSS
۶ تکه کد که هر برنامه‌نویس وب باید داشته باشه!

۱️⃣ مرکز کردن آیتم‌ها در گرید
.container {
display: grid;
place-items: center;
}

یه خط ساده که همه چیز رو وسط میاره! هم عمودی، هم افقی.

۲️⃣ پدینگ چپ و راست (با logical properties)
.button {
padding-inline: 1rem;
}

به جای padding-left و padding-right — یه دونه بنویس!

نکته: همین ترفند رو میتونی برای margin و border هم استفاده کنی:
• margin-inline / border-inline → چپ و راست
• padding-block / margin-block → بالا و پایین

۳️⃣ ستون‌های هم‌عرض در گرید
.container {
display: grid;
grid-auto-flow: column;
grid-auto-columns: 1fr;
}

هر تعداد ستون که داشته باشی، همه هم‌عرض میشن! عالی برای layoutهای داینامیک.

۴️⃣ استایل همزمان hover و focus
button:is(:hover, :focus) {
/* استایل خودت رو اینجا بنویس */
}

یه بار بنویس، برای هر دو حالت کار کنه! هم برای موس، هم برای کیبورد (accessibility).

۵️⃣ دایره کامل
.circle {
width: 2rem;
aspect-ratio: 1 / 1;
border-radius: 50%;
}

هرچیزی رو تبدیل به دایره می‌کنه! با aspect-ratio مطمئن میشی که همیشه square بمونه.

۶️⃣ حذف فاصله اضافی بین آیتم‌های گرید
.container {
gap: 0;
}

یا برای فاصله دلخواه:
.container {
gap: 1rem;
}

💡 چرا اینا کاربردی ان؟
• کوتاه و مینیمال — هر کدوم یه خطه
• مدرن — از قابلیت‌های جدید CSS استفاده می‌کنن
• کاربرد روزمره — توی هر پروژه‌ای بهشون نیاز داری

💎 @Htmlcss_channels | #HTML #css #JavaScript
  • ❤ 7
Post #2440 1.18K
✨ مجموعه‌ای از کدهای کوتاه ولی کاربردی CSS
۶ تکه کد که هر برنامه‌نویس وب باید داشته باشه


ارسال کدها در پست بعدی👇


💎 @Htmlcss_channels | #HTML #css #JavaScript
  • ❤ 5
  • 🔥 1
Post #2427 1.81K
💻 Responsive HTML Video با Orientation Media Query

💻 کد CSS:

* حالت عمودی (موبایل) *
@media screen and (orientation: portrait) {
  video {
    width: 100%;
    height: auto;
  }
}

* حالت افقی (دسکتاپ) *
@media screen and (orientation: landscape) {
  video {
    width: auto;
    height: 100vh;
    max-width: 100%;
  }
}


⚡ بهینه‌سازی بیشتر:
* فقط موبایل *
@media screen and (max-width: 768px) and (orientation: portrait) {
  video {
    object-fit: cover;
    aspect-ratio: 9/16;
  }
}

* فقط دسکتاپ *
@media screen and (min-width: 769px) and (orientation: landscape) {
  video {
    object-fit: contain;
    aspect-ratio: 16/9;
  }
}

🎬 مثال عملی:
<video controls poster="poster.jpg">
  <source src="video-mobile.mp4" media="(orientation: portrait)">
  <source src="video-desktop.mp4" media="(orientation: landscape)">
  Your browser does not support the video tag.
</video>



💎 @Htmlcss_channels | #HTML #css #JavaScript
  • ❤ 8
Older posts →
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →