我有2個畫布,一個使用HTML屬性width
和height
大小它,另一個使用CSS:帆布使用CSS但正常爲「寬度」 /「高度」屬性時拉伸
<canvas id="compteur1" width="300" height="300" onmousedown="compteurClick(this.id);"></canvas>
<canvas id="compteur2" style="width: 300px; height: 300px;" onmousedown="compteurClick(this.id);"></canvas>
Compteur1顯示器像它應該,但不compteur2。內容在300x300畫布上使用JavaScript繪製。
爲什麼會有顯示差異?
的確..我一直以爲像「寬度」和「高度」被拋棄了直接的屬性在最近的html版本中.. – Sirber 2010-04-09 00:02:03
哦,顯然它在http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#attr-canvas-寬度(section#'attr-canvas-width')。麻煩的是,我之前點擊了錯誤的'width',而是轉到了'#dom-canvas-width'部分。歸檔http://www.w3.org/Bugs/Public/show_bug.cgi?id=9469。 – SamB 2010-04-09 16:27:11
你救了我一個可怕的頭痛....謝謝! – nurxyz 2013-07-18 10:51:32