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

Pseudo-classes

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

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

  • Element state အလိုက် style ပြောင်းရန်

Pseudo-class ဆိုတာ element တစ်ခုရဲ့ state ကိုရွေးတာပါ။ Mouse တင်ထားတဲ့ :hover, input focus ဖြစ်တဲ့ :focus, list item အစီအစဉ်ရွေးတဲ့ :nth-child() စတာတွေဖြစ်ပါတယ်။ Interactive UI တွေမှာ hover/focus state မရှိရင် user က ဘာနှိပ်လို့ရလဲ ခန့်မှန်းရခက်တတ်ပါတယ်။

css
.button:hover {
  transform: translateY(-2px);
}

.input:focus {
  outline: 2px solid dodgerblue;
}

tr:nth-child(even) {
  background-color: #f6f8fa;
}
You should see
Button ကို hover လုပ်ရင် နည်းနည်းမြောက်သွားမယ်။ Input focus ဖြစ်ရင် outline ပေါ်မယ်။ Table row တွေကို alternating background ပေးနိုင်မယ်။

Warning

:focus style ကိုမဖျောက်ပါနဲ့။ Keyboard အသုံးပြုသူတွေအတွက် အရေးကြီးပါတယ်။

Pseudo-classes | Thuta Learning