[英]HTML attributes (width, height) of canvas change independently
I have some script on JS, it change width and height of canvas element: 我在JS上有一些脚本,它会更改canvas元素的宽度和高度:
function RefreshSizes (canvas) {
var temp_width = 320;
var temp_height = 240;
document.getElementById(canvas).setAttribute('width', temp_width);
document.getElementById(canvas).setAttribute('height', temp_height);
}
this functions calling right after canvas initializing. 此功能在画布初始化后立即调用。 It works fine on Chrome.
在Chrome上运行正常。
But in FireFox 49 I see that: 但是在FireFox 49中,我看到了:
What could it be? 会是什么呢?
UPD#1 Tested code of BukkitmanPlays MCPE UPD#1 BukkitmanPlays MCPE的经过测试的代码
UPD#2 Full CSS for canvas: UPD#2画布的完整CSS:
element {
width: 320px;
height: 240px;
}
.canvas {
border: 3px solid #E0E0E0;
z-index: 0;
position: relative;
}
html {
font: 10px/10px arial;
}
some code on one browser isn't the same on another browser, so in this case, what I would do: 一个浏览器上的某些代码与另一浏览器上的不同,因此在这种情况下,我该怎么做:
function RefreshSizes (canv) {
var temp_width = 320;
var temp_height = 240;
var canvas = canv;
canvas.width = temp_width;
canvas.height = temp_height;
}
I'm sure this will work 我敢肯定这会起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.