HTML အကိုးအကား

အက္ခရာဖြင့် HTML HTML အမျိုးအစားအလိုက် HTML Browser ပံ့ပိုးမှု HTML အရည်အချင်းများ HTML ကမ္ဘာလုံးဆိုင်ရာ အရည်အချင်းများ HTML ပွဲများ HTML အရောင်များ HTML Canvas HTML အသံ/ဗီဒီယို HTML အက္ခရာအစုံများ HTML Doctypes HTML URL ကုဒ် HTML ဘာသာစကားကုဒ်များ HTML နိုင်ငံကုဒ်များ HTTP မက်ဆေ့ခ်ျများ HTTP နည်းလမ်းများ PX မှ EM Converter ကီးဘုတ်ဖြတ်လမ်းများ


HTML canvas textBaseline Property

❮ HTML Canvas အကိုးအကား

ဥပမာ

y=100 တွင် အနီရောင်မျဉ်းတစ်ကြောင်းဆွဲပါ၊ ထို့နောက် မတူညီသော textBaseline တန်ဖိုးများဖြင့် စကားလုံးတစ်ခုစီကို y=100 တွင်ထည့်ပါ။

သင်၏ဘရောက်ဆာသည် HTML5canvastag ကိုမပံ့ပိုးပါ။

JavaScript-

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");

//Draw a red line at y = 100
ctx.strokeStyle = "red";
ctx.moveTo(5, 100);
ctx.lineTo(395, 100);
ctx.stroke();

ctx.font = "20px Arial"

//Place each word at y = 100 with different textBaseline values
ctx.textBaseline = "top";
ctx.fillText("Top", 5, 100);
ctx.textBaseline = "bottom";
ctx.fillText("Bottom", 50, 100);
ctx.textBaseline = "middle";
ctx.fillText("Middle", 120, 100);
ctx.textBaseline = "alphabetic";
ctx.fillText("Alphabetic", 190, 100);
ctx.textBaseline = "hanging";
ctx.fillText("Hanging", 290, 100);

Browser ပံ့ပိုးမှု

ဇယားရှိ နံပါတ်များသည် ပိုင်ဆိုင်မှုကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးသည်။

Property
textBaseline Yes 9.0 Yes Yes Yes

မှတ်ချက်- textBaseline ပိုင်ဆိုင်မှုသည် အထူးသဖြင့် "hanging" သို့မဟုတ် "ideographic" ကိုအသုံးပြုသည့်အခါ မတူညီသောဘရောက်ဆာများတွင် ကွဲပြားစွာအလုပ်လုပ်ပါသည်။


အဓိပ္ပါယ်နှင့် အသုံးပြုမှု

TextBaseline ပိုင်ဆိုင်မှုသည် စာသားဆွဲရာတွင် အသုံးပြုသည့် လက်ရှိစာသားအခြေခံလိုင်းကို သတ်မှတ်ပေးသည် သို့မဟုတ် ပြန်ပေးသည်။

အောက်ဖော်ပြပါပုံဥပမာသည် textBaseline ရည်ညွှန်းချက်ဖြင့် ပံ့ပိုးထားသော အမျိုးမျိုးသောအခြေခံအချက်များကို သရုပ်ပြသည်-

စာသားအခြေခံသရုပ်ဖော်ပုံ

မှတ်ချက်- fillText () နှင့် strokeText() နည်းလမ်းများသည် ကင်းဗတ်ပေါ်တွင် စာသားကို နေရာချထားသည့်အခါ သတ်မှတ်ထားသော textBaseline တန်ဖိုးကို အသုံးပြုပါမည်။

မူလတန်ဖိုး: အက္ခရာစဉ်
JavaScript syntax- စကား စပ် .textBaseline="အက္ခရာ|ထိပ်|တွဲ|အလယ်|သရုပ်ဖော်ပုံ|အောက်ခြေ";

အိမ်ခြံမြေတန်ဖိုးများ

Values Description Play it
alphabetic Default. The text baseline is the normal alphabetic baseline
top The text baseline is the top of the em square
hanging The text baseline is the hanging baseline
middle The text baseline is the middle of the em square
ideographic The text baseline is the ideographic baseline
bottom The text baseline is the bottom of the bounding box

❮ HTML Canvas အကိုးအကား