HTML DOM Element clientWidth
❮ Element Objectဥပမာ
padding အပါအဝင် "myDIV" ၏ အမြင့်နှင့် အကျယ်ကို ရယူပါ-
const elmnt = document.getElementById("myDIV");
let text = "Height with padding: " + elmnt.clientHeight + "px<br>";
text += "Width with padding: " + elmnt.clientWidth + "px";
အောက်တွင် နောက်ထပ် ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
ပိုင်ဆိုင်မှု သည် clientWidth
အကွက်များ၊ ဘောင် သို့မဟုတ် အနားသတ်များအပါအဝင် pixels ရှိ အရာတစ်ခု၏ ကြည့်ရှုနိုင်သော အကျယ်ကို ပြန်ပေးသည်။
clientWidth
ပိုင်ဆိုင်မှုသည် ဖတ်ရန်သာဖြစ်သည် ။
ကျူတိုရီရယ်
ကိုလည်းကြည့်ပါ-
Element သည် Height Property ကို လွန်ကဲသည်။
Element သည် Width Property ကို offset
ဒြပ်စင်တစ်ခုသို့ scrollbars များထည့်ရန် CSS overflow property ကိုသုံးပါ။
အထားအသို
element.clientWidth
တန်ဖိုးကို ပြန်ပေးသည်။
ရိုက်ပါ။ | ဖော်ပြချက် |
နံပါတ် | padding အပါအဝင် ဒြပ်စင်တစ်ခု၏ မြင်နိုင်သော အကျယ် (pixels)။ |
clientHeight/clientWidth နှင့် offsetHeight/offsetWidth အကြား ကွာခြားချက်
scrollbar မပါဘဲ
const elmnt = document.getElementById("myDIV");
let text = "";
text += "Height with padding: " + elmnt.clientHeight + "px<br>";
text += "Height with padding and border: " + elmnt.offsetHeight + "px<br>";
text += "Width with padding: " + elmnt.clientWidth + "px<br>";
text += "Width with padding and border: " + elmnt.offsetWidth + "px";
scrollbar ဖြင့်-
const elmnt = document.getElementById("myDIV");
let text = "";
text += "Height with padding: " + elmnt.clientHeight + "px<br>";
text += "Height with padding, border and scrollbar: " + elmnt.offsetHeight + "px<br>";
text += "Width with padding: " + elmnt.clientWidth + "px<br>";
text += "Width with padding, border and scrollbar: " + elmnt.offsetWidth + "px";
Browser ပံ့ပိုးမှု
element.clientWidth
ဘရောက်ဆာအားလုံးတွင် ထောက်ခံသည်-
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
❮ Element Object