Własność
HTMLCanvasElement.height
wyrażana jest w dodatniej liczbie całkowitej
odpowiada za atrybut height
elemetu HTML <canvas>
i jest interpretowany w pikselach CSS. Jeśli atrybut nie został określony, lub została przypisana do niego nieprawidłowa wartość, np. negatywna, zostanie użyta domyślna wartość 150
.To jedna z dwóch własności kontrolujących wielkość
<canvas>
, druga z nich to HTMLCanvasElement.width
.Składnia
var pxl = canvas.height; canvas.height = pxl;
Przykłady
Biorąc pod uwagę element <canvas>
:
<canvas id="canvas" width="300" height="300"></canvas>
Można sprawdzić jego wysokość za pomocą kodu:
var canvas = document.getElementById('canvas');
console.log(canvas.height); // 300
Specyfikacja
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'HTMLCanvasElement.height' in that specification. |
Living Standard |
Brak zmian od ostatniego snapshota, HTML5 |
HTML 5.1 The definition of 'HTMLCanvasElement.height' in that specification. |
Recommendation | |
HTML5 The definition of 'HTMLCanvasElement.height' in that specification. |
Recommendation | Snapshot HTML Living Standard zawierający początkową definicje. |
Zgodność przeglądarek
BCD tables only load in the browser
Zobacz też
- Interfejs definiujący tą własność,
HTMLCanvasElement
. - Inna własność kontrolujaca wielkość
<canvas>
,HTMLCanvasElement.width
.