Thuta Learning
ရှာဖွေရန်
IntermediateWeb Developmentbeginner

Z-Index

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

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

  • အလွှာအပေါ်အောက် စနစ်ကိုနားလည်ရန်

z-index က positioned elements တွေရဲ့ stack order ကိုထိန်းပါတယ်။ တန်ဖိုးကြီးလေ အပေါ်ရောက်လေပါ။ Modal, dropdown, tooltip, sticky header တွေမှာ မကြာခဏလိုပါတယ်။ သတိထားရမှာက z-index က stacking context ထဲမှာပဲအလုပ်လုပ်တာပါ။ တစ်ခါတလေ 9999 ထည့်လည်းမတက်တာက CSS က ဒေါသထွက်တာမဟုတ်၊ stacking context ကြောင့်ပါ။

css
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.modal {
  position: fixed;
  z-index: 101;
}
You should see
Backdrop က page တစ်ခုလုံးကိုဖုံးပြီး modal box က backdrop အပေါ်မှာပေါ်ပါမယ်။

Tip

Project ကြီးတွေမှာ z-index scale ကို 10, 20, 30, 100 စသလိုစနစ်တကျထားတာကောင်းပါတယ်။

Z-Index | Thuta Learning