Thuta Learning
CSS
ProjectsWeb Developmentအခြေခံ

Final Summary

CSSသင်ခန်းစာ 3125 မိနစ်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Cascade၊ box model၊ layout နဲ့ responsive ကို pipeline တစ်ခုအဖြစ် ချိတ်ဆက် ရှင်းပြနိုင်ဖို့
  • Layout တစ်ခုကို ကြည့်ပြီး flow၊ flexbox၊ grid၊ position ထဲက ဘာကို သုံးမလဲ ရွေးနိုင်ဖို့
  • Property တစ်ခု "အလုပ်မလုပ်" တဲ့အခါ လိုအပ်တဲ့ layout context ကို ရှာနိုင်ဖို့
  • @supports နဲ့ progressive enhancement ကို သုံးပြီး feature အသစ်တွေ ထည့်နိုင်ဖို့

ရိုးရိုးလေး ရှင်းပြမယ်

ရိုးရိုးလေး ရှင်းရရင်

CSS ရဲ့ အဓိက အကြောင်းအရာတွေကို သင်ပြီးသွားပါပြီ။ Selector နဲ့ element ရွေးတာ၊ အရောင်/font/စာသား/နောက်ခံ ညှိတာ၊ box model နဲ့ spacing ထိန်းတာ၊ Flexbox/Grid နဲ့ layout ဆောက်တာ၊ responsive design အတွက် media query ရေးတာတွေ အခြေခံကနေ လက်တွေ့အထိ နားလည်ပါပြီ။

CSS ကို သိတယ်ဆိုတာ property တွေ အလွတ်ကျက်တာ မဟုတ်ပါဘူး။ Website တစ်ခုကို ကြည့်လိုက်တာနဲ့ "ဒါကို box တွေအဖြစ် ဘယ်လို ခွဲပြီး ဆောက်မလဲ" လို့ တွေးနိုင်တာပါ။ ဒီအဆင့် ရောက်ရင် website တစ်ခုခု ကြည့်တိုင်း ခေါင်းထဲမှာ CSS ဦးနှောက်က တိတ်တိတ်လေး အလုပ်လုပ်နေပါလိမ့်မယ်။ ဒီ lesson က အဲဒီ တွေးခေါ်ပုံကို မေးခွန်းလေးခုအဖြစ် စုစည်းပေးပါတယ်။

Problem → Why → Solution

ပြဿနာ: property တွေ သိပေမယ့် ဘာကြောင့် အလုပ်မလုပ်လဲ မသိ

Learner တစ်ယောက်က hero section ရဲ့ စာကို screen အလယ်တည့်တည့် ထားချင်ပါတယ်။ "Centre လုပ်ရင် flex နဲ့ align-items: center" ဆိုတာ အလွတ်ရပြီး height: 100% ကိုလည်း ထည့်လိုက်ပါတယ်။ ရလဒ်ကတော့ စာက page ရဲ့ အပေါ်ဆုံးမှာပဲ ကပ်နေပါတယ်။ နောက်တော့ margin-top: 300px ထည့်ကြည့်ပြီး laptop မှာ "အလယ်ရောက်ပြီ" ထင်လိုက်ပေမယ့် phone မှာ screen အောက်ကို ကျသွားပါတယ်။

Framework utility class နာမည်တွေ သိပေမယ့် နောက်ကွယ်က CSS behaviour ကို နားမလည်ရင်လည်း ဒီလိုပါပဲ။ Class ကို ထည့်ပြီး မရရင် ဘာဆက်လုပ်ရမလဲ မသိတော့ပါဘူး။

.hero {
  display: flex;
  align-items: center;     /* centre... in what height? */
  justify-content: center;
  height: 100%;            /* 100% of the body's auto height */
}

Layout context ပျောက်နေတာပါ

align-items: center က container ထဲက အပို နေရာမှာ item ကို အလယ်ထားတာပါ။ height: 100% က parent ရဲ့ definite height ရှိမှ အလုပ်လုပ်ပါတယ်။ body ရဲ့ height က auto ဖြစ်လို့ .hero ရဲ့ height လည်း content အမြင့်ပဲ ဖြစ်ပြီး အလယ်ထားစရာ အပိုနေရာ မရှိပါဘူး။ min-height: 100vh လို screen အမြင့်ကို တိုက်ရိုက် ပေးရင် ပြဿနာ ပြေလည်ပါတယ်။ "ဘယ် property" ထက် "ဘယ် context ထဲမှာ" ကို မေးတတ်ဖို့ လိုပါတယ်။

Core concept: element တိုင်း ဖြေရတဲ့ မေးခွန်းလေးခု

Browser က element တစ်ခုကို screen ပေါ် ဆွဲတဲ့အခါ ဒီမေးခွန်းလေးခုကို အစဉ်လိုက် ဖြေပါတယ်။ Course ရဲ့ chapter တိုင်းက ဒီမေးခွန်းတစ်ခုခုရဲ့ အဖြေပါ။ Bug တစ်ခု တွေ့ရင်လည်း ဘယ်မေးခွန်းမှာ အဖြေမှားလဲ ရှာရုံပါပဲ။

text
The CSS pipeline
----------------
 HTML element
     |
     v
 [1] Cascade -----> computed values (color, width, ...)
     |
     v
 [2] Box model ---> content + padding + border + margin
     |
     v
 [3] Layout ------> flow | flex | grid | position
     |
     v
 [4] Adapt -------> fluid units, media / container queries

၁။ Value တွေ ဘယ်ကရလဲ (cascade)

Selector တွေက element ကို match လုပ်ပြီး ပြိုင်ဆိုင်တဲ့ rule တွေကြားမှာ origin၊ specificity၊ source order အစဉ်နဲ့ အနိုင်ရသူကို ရွေးပါတယ်။ color၊ font လို property တွေက parent ကနေ inherit ဖြစ်ပြီး custom property တွေလည်း inherit ဖြစ်ပါတယ်။

၂။ Box ဘယ်လောက်ကြီးလဲ (box model)

Content၊ padding၊ border၊ margin ပေါင်းပြီး box ဖြစ်ပါတယ်။ box-sizing: border-box က width ထဲမှာ padding နဲ့ border ကို ထည့်တွက်ပါတယ်။ Width မပေးရင် block က parent အကျယ်ကို ဖြည့်ပြီး height က content ပေါ် မူတည်ပါတယ်။

၃။ ဘယ် layout က နေရာချလဲ

Normal flow က default ပါ။ Item တွေကို တစ်ဘက်တည်း (row ဒါမှမဟုတ် column) စီရင် flexbox၊ row နဲ့ column နှစ်ဘက်လုံး ထိန်းရင် grid ကို သုံးပါ။ position: absolute/fixed က element ကို flow ထဲက ထုတ်ပြီး containing block နဲ့ နေရာချပါတယ်။

၄။ ဘယ်လို လိုက်ပြောင်းလဲ

min()၊ clamp()၊ %၊ rem လို fluid value တွေက screen တိုင်းမှာ အလုပ်လုပ်ပြီး content ပျက်တဲ့နေရာမှာမှ media query ဒါမှမဟုတ် container query ထည့်ပါတယ်။ hover၊ dark mode၊ reduced motion လို user preference တွေကိုလည်း ဒီအဆင့်မှာ လေးစားပါတယ်။

လုပ်ချင်တာရွေးရမယ့် tool
Nav link တွေကို တစ်တန်းတည်း စီFlexbox + gap
Sidebar + main page shellGrid (grid-template-columns)
Card ပေါ်မှာ badge ကပ်position: relative + absolute
Theme အရောင်တွေ မျှဝေCustom properties
Mental model: မေးခွန်းလေးခု pipeline
  1. Cascade: ဘယ် value နိုင်လဲ
  2. Box: ဘယ်လောက် ကြီးလဲ
  3. Layout: ဘယ်သူ နေရာချလဲ
  4. Adapt: ဘယ်လို လိုက်ပြောင်းလဲ

Bug တစ်ခု တွေ့ရင် pipeline ကို အပေါ်ကနေ အောက်ကို လိုက်စစ်ပါ။ အဖြေမှားတဲ့ ပထမဆုံး မေးခွန်းက ပြင်ရမယ့်နေရာပါ။

အခြေခံ ပုံစံ

css
:root { --token: value; }                    /* 1. shared values */
*, *::before, *::after { box-sizing: border-box; }   /* 2. predictable boxes */

.shell { display: grid; gap: var(--token); }  /* 3. two-dimensional layout */
.row { display: flex; gap: var(--token); }    /* 3. one-dimensional layout */

@media (min-width: BREAKPOINT) {             /* 4. adapt where content breaks */
  .shell { grid-template-columns: MAIN SIDE; }
}

Stylesheet အများစုရဲ့ အရိုးစုက ဒီပုံစံပါ။ Token တွေ၊ box-sizing reset၊ page shell အတွက် grid၊ component အတွင်းပိုင်းအတွက် flex နဲ့ content ပျက်တဲ့ width မှာ breakpoint တို့ပါ။

Course တစ်ခုလုံးကို page တစ်ခုထဲမှာ

အောက်က page တိုလေးမှာ chapter တိုင်းက အကြောင်းအရာ တစ်ခုစီ ပါပါတယ်။ Custom property၊ box-sizing၊ flex header၊ grid shell၊ fluid width၊ hover transition နဲ့ mobile-first media query တို့ပါ။ Run ပြီး line တစ်ကြောင်းချင်းစီက pipeline ရဲ့ ဘယ်မေးခွန်းကို ဖြေနေလဲ ရှာကြည့်ပါ။

index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>CSS in one page</title>
  <style>
    :root { --accent: #2563eb; --space: 16px; --radius: 12px; }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; font-family: system-ui, sans-serif; line-height: 1.6; }

    .site-header {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: var(--space);
      padding: var(--space);
      background: #0f172a;
      color: #fff;
    }

    .site-header nav { display: flex; gap: var(--space); }
    .site-header a { color: inherit; }

    .page {
      display: grid;
      gap: var(--space);
      width: min(100% - 2 * var(--space), 1100px);
      margin: var(--space) auto;
    }

    .card {
      padding: var(--space);
      border: 1px solid #cbd5e1;
      border-radius: var(--radius);
      transition: border-color 0.2s;
    }

    .card:hover { border-color: var(--accent); }

    @media (min-width: 768px) {
      .page { grid-template-columns: 2fr 1fr; }
    }
  </style>
</head>
<body>
  <header class="site-header">
    <strong>CSS Notes</strong>
    <nav><a href="#">Guides</a><a href="#">Projects</a></nav>
  </header>
  <main class="page">
    <article class="card">Main content: normal flow inside a grid cell.</article>
    <aside class="card">Sidebar: stacks below the article on phones.</aside>
  </main>
</body>
</html>

Code ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်

  1. Tokens (cascade):root { --accent: #2563eb; --space: 16px; --radius: 12px; }

    Custom property တွေက :root ကနေ element တိုင်းဆီ inherit ဖြစ်လို့ spacing နဲ့ အရောင်ကို တစ်နေရာတည်းမှာ ထိန်းပါတယ်။

  2. One-dimensional layoutjustify-content: space-between;

    Header က row တစ်ခုတည်းပါ။ Logo ကို ဘယ်၊ nav ကို ညာ တွန်းပြီး flex-wrap ကြောင့် နေရာမလောက်ရင် nav က အောက်တန်း ဆင်းပါတယ်။

  3. Fluid shellwidth: min(100% - 2 * var(--space), 1100px);

    min() ထဲမှာ var() နဲ့ တွက်ချက်မှုကို တွဲသုံးလို့ရပါတယ်။ ဘေးနှစ်ဖက် 16px gutter ချန်ပြီး 1100px မှာ ရပ်ပါတယ်။

  4. Two-dimensional layout.page { grid-template-columns: 2fr 1fr; }

    Media query ထဲမှာပဲ ရှိလို့ 768px နဲ့အထက်မှာ ကျန်နေရာကို 2:1 ခွဲပါတယ်။ အောက်မှာတော့ grid ရဲ့ default column တစ်ခုနဲ့ card တွေ အပေါ်အောက် စီပါတယ်။

  5. State + motion.card:hover { border-color: var(--accent); }

    Pseudo-class နဲ့ transition ပေါင်းပြီး border အရောင် 0.2s အတွင်း ချောချောမွေ့မွေ့ ပြောင်းပါတယ်။

You should see
အပေါ်မှာ အပြာရင့် header (ဘယ်ဘက် "CSS Notes"၊ ညာဘက် link နှစ်ခု)။ 767px အထိ article နဲ့ aside card တွေ အပေါ်အောက်၊ 768px နဲ့အထက်မှာ article က 2fr၊ aside က 1fr နဲ့ ဘေးချင်းကပ်။ Card ကို hover လုပ်ရင် border အပြာရောင် ပြောင်းပါတယ်။

နောက်ထပ် ဘာဆက်လေ့လာမလဲ

  • HTML semantic structure ကို ပိုနက်နက်နဲနဲ လေ့လာပါ (header၊ main၊ nav၊ article၊ form label)
  • Flexbox/Grid နဲ့ practice layout ၅ ခု ဆောက်ပါ (navbar၊ hero၊ pricing၊ dashboard၊ gallery)
  • Mobile-first landing page တစ်ခုကို အစအဆုံး ဆောက်ပါ
  • CSS variable တွေနဲ့ အရောင်၊ spacing၊ radius ပါတဲ့ design system သေးသေးလေး တစ်ခု လုပ်ပါ
  • အဲဒီနောက် JavaScript နဲ့ interaction ထည့်ပါ

Feature အသစ်တွေ (container query၊ :has()၊ subgrid စသည်) ကို သုံးတဲ့အခါ progressive enhancement လုပ်ပါ။ Browser တိုင်းမှာ အလုပ်လုပ်တဲ့ base layout ကို အရင်ရေးပြီး feature ပံ့ပိုးတဲ့ browser တွေမှာမှ @supports နဲ့ ပိုကောင်းအောင် ထပ်ဖြည့်ပါ။ Browser support ကို MDN ရဲ့ compatibility table ဒါမှမဟုတ် caniuse.com မှာ စစ်နိုင်ပါတယ်။

enhance.css
.gallery { display: flex; flex-wrap: wrap; gap: 16px; }   /* works everywhere */

@supports (display: grid) {
  .gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

လက်တွေ့ project တွေမှာ

လက်တွေ့ project တွေမှာ

Job interview တွေနဲ့ code review တွေမှာ "ဒီ property ရဲ့ syntax ဘာလဲ" ထက် "ဒီ layout ကို ဘယ်လို ချဉ်းကပ်မလဲ"၊ "ဒီ element ဘာလို့ မလိုက်တာလဲ" ကို ပိုမေးလေ့ရှိပါတယ်။ Syntax ကို MDN မှာ စက္ကန့်ပိုင်းနဲ့ ရှာလို့ရပေမယ့် ပြဿနာကို pipeline နဲ့ ခွဲစိတ်တတ်တာကတော့ အတွေ့အကြုံကနေပဲ ရပါတယ်။

Tailwind၊ Bootstrap လို framework တွေကို သုံးတဲ့ team တွေမှာလည်း ဒီ အခြေခံက တူတူပါပဲ။ flex၊ grid-cols-3၊ md: prefix တွေက ဒီ course က property နဲ့ media query တွေပဲ ဖြစ်ပါတယ်။ Framework ပြောင်းသွားရင်တောင် CSS နားလည်မှုက ဆက်အသုံးဝင်ပါတယ်။ အကောင်းဆုံး လေ့ကျင့်နည်းကတော့ mini project တွေပါ။ Profile card၊ pricing section၊ navbar၊ hero section၊ dashboard card grid တွေကို တစ်ခုချင်း ဆောက်ရင်း CSS muscle memory တိုးလာပါလိမ့်မယ်။

အမှားများ

Course ပြီးခါနီးမှာ ဖြစ်လေ့ရှိတဲ့ အမှားများ

Layout တိုင်းအတွက် grid (ဒါမှမဟုတ် flex) တစ်မျိုးတည်း သုံးတာ

Grid ကို ကြိုက်လို့ button ထဲက icon နဲ့ စာကိုပါ grid နဲ့ စီတာ၊ flex ကို ကြိုက်လို့ page shell ကို flex-basis % တွေနဲ့ ဆောက်တာ ဖြစ်တတ်ပါတယ်။ အလုပ်လုပ်ပေမယ့် code ရှုပ်ပါတယ်။ "တစ်ဘက်လား၊ နှစ်ဘက်လား" လို့ မေးပြီးမှ ရွေးပါ။

Context မစစ်ဘဲ property ထပ်ထည့်တာ

Problem section ရဲ့ height: 100% လိုပဲ top/left က position မပါရင်၊ z-index က positioned မဖြစ်ရင်၊ justify-self က flex item မှာ အလုပ်မလုပ်ပါဘူး။ Property တစ်ခု သက်ရောက်မှု မရှိရင် နောက်ထပ် property ထည့်တာထက် အဲဒီ property လိုအပ်တဲ့ context ကို MDN မှာ စစ်ပါ။

Tutorial ကြည့်ပြီး ကိုယ်တိုင် မဆောက်တာ

Video နဲ့ article တွေ ဆက်တိုက် ကြည့်ရင် နားလည်သလို ခံစားရပေမယ့် file အလွတ်တစ်ခု ဖွင့်လိုက်တဲ့အခါ ဘယ်ကစရမလဲ မသိဖြစ်တတ်ပါတယ်။ ရိုးရှင်းတဲ့ website တစ်ခုရဲ့ section တစ်ခုကို ကူးဆောက်ကြည့်ပြီး ကိုယ့်ဖြေရှင်းနည်းကို DevTools နဲ့ မူရင်းနဲ့ နှိုင်းယှဉ်ပါ။

Mini challenge

Toolkit အပြည့်နဲ့ pricing section

Plan သုံးခုပါတဲ့ pricing section တစ်ခုကို ဆောက်ပါ။ Phone မှာ အပေါ်အောက် စီပြီး 800px နဲ့အထက်မှာ column သုံးခု ဖြစ်ရပါမယ်။ အလယ် plan ကို "featured" အဖြစ် custom property တစ်ခုကို override လုပ်ရုံနဲ့ အရောင်ပြောင်းပါ။

  • .plan က --plan-accent ကို border နဲ့ button နောက်ခံမှာ သုံးရပါမယ်
  • .plan--featured က --plan-accent ကိုပဲ override လုပ်ရပါမယ်
  • Price ကို clamp() နဲ့ fluid font size ပေးပါ
  • Mobile-first: base က column တစ်ခု၊ @media (min-width: 800px) မှာ သုံးခု
  • Button တွေမှာ :focus-visible outline ရှိရပါမယ်
pricing.css
/* Markup: section.pricing > article.plan*3 (middle one also .plan--featured),
   each with h3, p.price and a.plan__cta */

.pricing {
  /* TODO: mobile-first grid, gap, fluid width, centred */
}

.plan {
  --plan-accent: #64748b;
  /* TODO: padding, radius, border in the accent colour */
}

.plan--featured {
  /* TODO: override one custom property only */
}

.price {
  /* TODO: clamp() font size */
}

/* TODO: .plan__cta uses the accent; add a :focus-visible outline */
/* TODO: three columns from 800px */

ရလဒ်: 375px မှာ plan သုံးခု အပေါ်အောက်၊ 1024px မှာ တစ်တန်းတည်း။ Featured plan ရဲ့ border နဲ့ button က အပြာ၊ ကျန်နှစ်ခုက မီးခိုးရောင် ဖြစ်ပြီး price စာလုံးက screen ကျယ်လာတာနဲ့ ကြီးလာပါတယ်။

အရိပ်အမြွက် ကြည့်ရန်

Custom property တွေ inherit ဖြစ်လို့ .plan--featured မှာ --plan-accent ကို ပြောင်းလိုက်ရင် အဲဒီ card ထဲက border နဲ့ button နှစ်ခုလုံး လိုက်ပြောင်းပါတယ်။ Rule အသစ် ထပ်ရေးစရာ မလိုပါဘူး။

အဖြေ ကြည့်ရန်
pricing.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style>
    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; font-family: system-ui, sans-serif; }

    .pricing {
      display: grid;
      gap: 16px;
      width: min(100% - 32px, 1000px);
      margin: 32px auto;
    }

    .plan {
      --plan-accent: #64748b;
      padding: 20px;
      border: 2px solid var(--plan-accent);
      border-radius: 12px;
    }

    .plan--featured { --plan-accent: #2563eb; }

    .price { margin: 8px 0 16px; font-size: clamp(1.75rem, 1.25rem + 2vw, 2.5rem); }

    .plan__cta {
      display: inline-block;
      padding: 10px 16px;
      border-radius: 8px;
      background: var(--plan-accent);
      color: #fff;
      text-decoration: none;
    }

    .plan__cta:focus-visible {
      outline: 3px solid var(--plan-accent);
      outline-offset: 3px;
    }

    @media (min-width: 800px) {
      .pricing { grid-template-columns: repeat(3, 1fr); }
    }
  </style>
</head>
<body>
  <section class="pricing">
    <article class="plan"><h3>Free</h3><p class="price">$0</p>
      <a class="plan__cta" href="#">Start</a></article>
    <article class="plan plan--featured"><h3>Pro</h3><p class="price">$12</p>
      <a class="plan__cta" href="#">Upgrade</a></article>
    <article class="plan"><h3>Team</h3><p class="price">$40</p>
      <a class="plan__cta" href="#">Contact</a></article>
  </section>
</body>
</html>

Quick Quiz 1 / 3

Header တစ်ခု၊ ဘယ်ဘက် sidebar တစ်ခု၊ main area တစ်ခု၊ footer တစ်ခု ပါတဲ့ page shell အတွက် ဘာက အသင့်တော်ဆုံးလဲ။

Quick Quiz 2 / 3

Parent ရဲ့ height က auto ဖြစ်ပြီး child မှာ height: 100% ပေးထားရင် child ရဲ့ height က ဘာဖြစ်မလဲ။

Quick Quiz 3 / 3

Challenge solution မှာ .plan--featured { --plan-accent: #2563eb; } ပဲ ပြောင်းထားပါတယ်။ Featured card ထဲက .plan__cta ရဲ့ နောက်ခံ ဘာရောင်လဲ။

မှတ်ထားရမယ့် အချက်များ

  • Element တိုင်းက cascade → box model → layout → adapt pipeline ကို ဖြတ်သွားပါတယ်
  • တစ်ဘက်တည်း layout အတွက် flexbox၊ row နဲ့ column နှစ်ဘက်လုံးအတွက် grid ကို ရွေးပါ
  • Property အလုပ်မလုပ်ရင် ထပ်မထည့်ခင် လိုအပ်တဲ့ context (definite height၊ position) ကို စစ်ပါ
  • Feature အသစ်တွေကို @supports နဲ့ progressive enhancement အဖြစ် ထည့်ပါ
  • Mini project တွေ တစ်ခုချင်း ဆောက်တာက CSS ကို ခိုင်မာစေတဲ့ အကောင်းဆုံး လေ့ကျင့်ခန်းပါ

CSS Snapshot 2025 — W3C

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Final Summary | Thuta Learning