Grid နဲ့ Row၊ Column စီခြင်း
W3C CSS Snapshot 2026
Grid က အကြောင်းအရာတွေကို row နဲ့ column အလိုက် စီပေးပါတယ်။ Parent မှာ display: grid ရေးပါ။ Row၊ column နဲ့ အကွာအဝေးကို container မှာ သတ်မှတ်ပြီး item တစ်ခုချင်းကို လိုသလို နေရာချနိုင်ပါတယ်။
Code စမ်းလို့ရတဲ့ သင်ခန်းစာ ဖွင့်ရန်
ဒီစာမျက်နှာမှာ
Grid Container မှာ သတ်မှတ်တဲ့ Property များ
- display
Grid container တစ်ခု ဖန်တီးပါ။ တိုက်ရိုက် child တွေက grid item ဖြစ်လာပါတယ်။
- grid-template-columns
Explicit column တွေကို သတ်မှတ်ပါ။ Track အရွယ်တွေကို inline axis အစကနေ အဆုံးအထိ စဉ်လိုက် ရေးပါတယ်။
- grid-template-rows
Explicit row တွေကို သတ်မှတ်ပါတယ်။ တန်ဖိုးတွေကို block axis အစဉ်အတိုင်း ရေးပါ။
- grid-template-areas
နာမည်ပေးထားတဲ့ area တွေနဲ့ grid ပုံဆွဲပါတယ်။ Row တစ်ခုစီကို quotation mark နဲ့ ရေးပြီး နာမည်တူအကွက်တွေကို စတုဂံပုံ ထားပါ။
- grid-auto-columns
Explicit column စာရင်းအပြင်ဘက်မှာ ထပ်ပေါ်လာတဲ့ column တွေရဲ့ အကျယ်ကို သတ်မှတ်ပါတယ်။
- grid-auto-rows
Explicit row စာရင်းအပြင်ဘက်မှာ ထပ်ပေါ်လာတဲ့ row တွေရဲ့ အမြင့်ကို သတ်မှတ်ပါတယ်။
- grid-auto-flow
အလိုအလျောက် နေရာချတဲ့အခါ row အရင်ဖြည့်မလား၊ column အရင်ဖြည့်မလား၊ အရင်ကျန်တဲ့ အကွက်လွတ်ကို ပြန်ဖြည့်မလား သတ်မှတ်ပါတယ်။
- grid-template
Explicit row၊ column နဲ့ လိုအပ်ရင် နာမည်ပေးထားတဲ့ area ကို declaration တစ်ခုတည်းနဲ့ သတ်မှတ်ပါတယ်။
- grid shorthand
Explicit grid သို့မဟုတ် implicit grid ကို တစ်ကြောင်းတည်း သတ်မှတ်ပါတယ်။ မရေးခဲ့တဲ့ template နဲ့ auto-placement property တွေကို မူလတန်ဖိုး ပြန်ထားပါတယ်။
- gap
Grid row တွေကြားနဲ့ column တွေကြား အကွာအဝေး သတ်မှတ်ပါတယ်။ Gap က track တွေကြားမှာ ရှိပါတယ်။
- row-gap
Grid row တွေကြား အကွာအဝေး သတ်မှတ်ပါတယ်။
- column-gap
Grid column တွေကြား အကွာအဝေး သတ်မှတ်ပါတယ်။
- justify-items
Cell အတွင်း item တွေရဲ့ inline axis alignment ကို အားလုံးအတွက် သတ်မှတ်ပါတယ်။ အလျားလိုက် စာရေးပုံမှာ ဘယ်ညာ axis ပါ။
- align-items
Cell အတွင်း item တွေရဲ့ block axis alignment ကို အားလုံးအတွက် သတ်မှတ်ပါတယ်။
- justify-content
Grid column အစုက container ထက် ကျဉ်းတဲ့အခါ inline axis ပေါ်မှာ column အစုကို နေရာချပါတယ်။
- align-content
Grid row အစုက container ထက် ပိုတိုတဲ့အခါ block axis ပေါ်မှာ row အစုကို နေရာချပါတယ်။
- place-items
Container မှာ align-items နဲ့ justify-items ကို တစ်ခါတည်း သတ်မှတ်ပါတယ်။
- place-content
Container အတွင်းက track အစုအတွက် align-content နဲ့ justify-content ကို တစ်ခါတည်း သတ်မှတ်ပါတယ်။
Grid Item မှာ သတ်မှတ်တဲ့ Property များ
- grid-column
Column တွေတစ်လျှောက် item ရဲ့ စမယ့် line နဲ့ ဆုံးမယ့် line ကို ရွေးပါတယ်။ grid-column-start နဲ့ grid-column-end ကို တစ်ခါတည်း သတ်မှတ်ပါတယ်။
- grid-row
Row တွေတစ်လျှောက် item ရဲ့ စမယ့် line နဲ့ ဆုံးမယ့် line ကို ရွေးပါတယ်။ grid-row-start နဲ့ grid-row-end ကို တစ်ခါတည်း သတ်မှတ်ပါတယ်။
- grid-column-start
Grid item ရဲ့ column axis ပေါ်မှာ စမယ့် line ကို သတ်မှတ်ပါတယ်။
- grid-column-end
Grid item ရဲ့ column axis ပေါ်မှာ ဆုံးမယ့် line ကို သတ်မှတ်ပါတယ်။
- grid-row-start
Grid item ရဲ့ row axis ပေါ်မှာ စမယ့် line ကို သတ်မှတ်ပါတယ်။
- grid-row-end
Grid item ရဲ့ row axis ပေါ်မှာ ဆုံးမယ့် line ကို သတ်မှတ်ပါတယ်။
- grid-area
Item တစ်ခုကို နာမည်ပေးထားတဲ့ area မှာ ထားနိုင်သလို ဘောင်လေးဖက်ကို တန်ဖိုးနဲ့လည်း သတ်မှတ်နိုင်ပါတယ်။
- justify-self
Grid item တစ်ခုတည်းရဲ့ inline axis alignment ကို ပြောင်းပါတယ်။
- align-self
Grid item တစ်ခုတည်းရဲ့ block axis alignment ကို ပြောင်းပါတယ်။
- place-self
Item တစ်ခုတည်းအတွက် align-self နဲ့ justify-self ကို တစ်ခါတည်း ရေးပါတယ်။
- order
Grid က အလိုအလျောက် နေရာချတဲ့အစဉ်ကို ပြောင်းပါတယ်။ ဖတ်ရလွယ်ပြီး keyboard နဲ့ ရွှေ့ရလွယ်ဖို့ HTML အစဉ်ကို သေချာရေးပါ။
fr နဲ့ Column အကျယ် ခွဲပုံ
grid-template-columns မှာ column တစ်ခုစီရဲ့ အကျယ်သတ်မှတ်ပါတယ်။ fr က ပုံသေအကျယ်နဲ့ gap တွေ နုတ်ပြီး ကျန်တဲ့နေရာကို ခွဲပေးပါတယ်။ 1fr နှစ်ခုဆို နေရာတူတူ ရပါတယ်။ Items တွေက column အစဉ်လိုက်ဝင်ပြီး ပြည့်ရင် နောက် row ဆင်းပါတယ်။
စမ်းသပ်နည်း ဒီနမူနာကို .html ဖိုင်အသစ်အဖြစ် သိမ်းပြီး browser နဲ့ ဖွင့်ပါ။ ပြင်ပြီးတိုင်း save နဲ့ reload လုပ်ပါ။
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Divide the available width with fr</title>
<style>
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cards > div { background: #d6efea; padding: 12px; }
</style>
</head>
<body>
<div class="cards"><div>Pen</div><div>Notebook</div><div>Folder</div></div>
</body>
</html>
စမ်းကြည့်ရင် ဘာဖြစ်မလဲ Pen နဲ့ Notebook က ပထမ row မှာ၊ Folder က နောက် row မှာ ပေါ်ပါမယ်။ 1fr 2fr ပြောင်းစမ်းပါ။
Named Area နဲ့ Page အပိုင်း နေရာချခြင်း
grid-template-areas ထဲမှာ row တစ်ကြောင်းစီကို quotation marks နဲ့ ရေးပြီး layout ပုံစံ ချပါတယ်။ Row တစ်ခုထဲမှာ နာမည်တူ ထပ်ရေးရင် အဲဒီနာမည်က column တွေကို ဖြတ်ယူပါတယ်။ နာမည်တူတဲ့ အကွက်တွေက ထောင့်မှန်စတုဂံတစ်ခု ဖြစ်ရပါမယ်။ အကွက်လွတ်အတွက် အစက် (.) သုံးပါ။ grid-area နဲ့ item ကို သက်ဆိုင်ရာ နာမည်ပေးထားတဲ့ နေရာမှာ ထားပါတယ်။
စမ်းသပ်နည်း ဒီနမူနာကို .html ဖိုင်အသစ်အဖြစ် သိမ်းပြီး browser နဲ့ ဖွင့်ပါ။ ပြင်ပြီးတိုင်း save နဲ့ reload လုပ်ပါ။
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Place page regions with named areas</title>
<style>
.page { display: grid; gap: 8px; grid-template-columns: 7rem minmax(0, 1fr);
grid-template-areas: "head head" "side content"; }
.page > * { background: #d6efea; padding: 8px; }
header { grid-area: head; }
aside { grid-area: side; }
main { grid-area: content; }
</style>
</head>
<body>
<div class="page"><header>Example Store</header><aside>Categories</aside><main>Pens and notebooks</main></div>
</body>
</html>
စမ်းကြည့်ရင် ဘာဖြစ်မလဲ ခေါင်းစဉ်က column နှစ်ခုလုံး ယူပါတယ်။ ဒုတိယ row မှာ Categories နဲ့ product list ဘေးချင်းကပ် ပေါ်ပါမယ်။
ဆက်လေ့လာရန် သင်ခန်းစာများ
- Track၊ cell နဲ့ grid line တွေကို ရေတွက်ပုံ
- Browser က ထပ်ထည့်တဲ့ row တွေရဲ့ အမြင့် သတ်မှတ်ပုံ
- Grid line တွေကို နာမည်ပေးပြီး စာသားအလိုက် အကျယ်ခွဲပုံ
- Grid တစ်ခုလုံးကို ညှိတာနဲ့ cell ထဲက item ကို ညှိတာ
- Grid က item တွေကို ဘယ်အစဉ်နဲ့ နေရာချသလဲ
- Grid area တစ်ခုထဲမှာ item တွေ ထပ်ထားပုံ
- ဆံ့တဲ့ Column အရေအတွက်ကို Grid နဲ့ ရွေးခြင်း
- Card နှစ်ခုနဲ့ auto-fill၊ auto-fit ကို နှိုင်းယှဉ်ပုံ
- subgrid နဲ့ အတွင်းက အကွက်တွေကို parent column အတိုင်း ညှိပုံ