attr function

attr function သည် HTML tag ၏ attribute တန်ဖိုးကို CSS တွင် ရယူနိုင်စေပါသည်။

Syntax

cssselector {
  property: attr(name, type, fallback);
}

Parameters

Parameter Description
name CSS သို့ ပေးပို့သော element ၏ attribute အမည်။
type CSS property ၏ တန်ဖိုးအမျိုးအစား။ အောက်ပါ keyword များ ခွင့်ပြုထားသည်။ string, color, url, integer, number, angle, time, deg, ထို့ပြင် em, px စသည့် CSS unit များ။
fallback Attribute မရှိပါက သို့မဟုတ် browser မှ ရယူ၍မရပါက အသုံးပြုမည့် တန်ဖိုး။

Example

Link တစ်ခု၏ စာသားပြီးနောက်တွင် ၎င်း၏ href attribute တန်ဖိုးကို ကွင်းစကွင်းပွင်း အတွင်း ဖော်ပြကြပါစို့။

html<a href="http://google.com">link</a>
cssa::after {
  content: ' (' attr(href) ')';
}

Результат:

See also

  • content property,
    သည် element များတွင် စာသားများ ထည့်သွင်းခွင့်ပြုပေးသည်။
  • ::before pseudoelement,
    သည် tag ၏ စာသားအပြီးတွင် ထည့်သွင်းပေးသည်။
  • ::after pseudoelement,
    သည် tag ၏ စာသားမစခင်တွင် ထည့်သွင်းပေးသည်။