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

Position Property

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

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

  • Element နေရာချထားပုံကိုထိန်းရန်

position က element ရဲ့နေရာချထားပုံကိုထိန်းပါတယ်။ Default က static ပါ။ relative က မူလနေရာကိုအခြေခံပြီးနည်းနည်းရွှေ့ချင်တဲ့အခါသုံးတယ်။ absolute က positioned parent ကိုမူတည်ပြီးနေရာချတယ်။ fixed က browser viewport ကိုကပ်ထားတာဖြစ်ပြီး scroll လုပ်လည်းမရွေ့ပါ။ sticky က normal flow နဲ့ fixed ကြားက hybrid လိုပါပဲ။

css
.chat-button {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
}

.badge {
  position: absolute;
  top: 8px;
  right: 8px;
}
You should see
Chat button က browser ညာဘက်အောက်မှာအမြဲပေါ်နေမယ်။ Badge က parent card ရဲ့ ညာဘက်အပေါ်မှာကပ်နေပါမယ်။

Warning

absolute သုံးတဲ့အခါ parent မှာ position: relative; မထားမိရင် မမျှော်လင့်တဲ့နေရာကိုခုန်သွားတတ်ပါတယ်။

Position Property | Thuta Learning