HTML DOM Öğesi clientHeight
❮ Öğe NesnesiÖrnek
Dolgu dahil "myDIV" yüksekliğini ve genişliğini alın:
const elmnt = document.getElementById("myDIV");
let text = "Height with padding: " + elmnt.clientHeight + "px<br>";
text += "Width with padding: " + elmnt.clientWidth + "px";
Aşağıda daha fazla örnek.
Tanım ve Kullanım
Özellik clientHeight
, kenarlık, kaydırma çubuğu veya kenar boşluğu değil, dolgu dahil piksel cinsinden bir öğenin görüntülenebilir yüksekliğini döndürür.
clientHeight
Mülk salt okunurdur .
Sözdizimi
element.clientHeight
Geri dönüş değeri
Tip | Açıklama |
Numara | Dolgu dahil öğenin görüntülenebilir yüksekliği (piksel olarak) |
clientHeight/clientWidth ve offsetHeight/offsetWidth arasındaki fark
Kaydırma çubuğu olmadan:
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";
Bir kaydırma çubuğu ile:
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";
Tarayıcı Desteği
element.clientHeight
tüm tarayıcılarda desteklenir:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
❮ Öğe Nesnesi