蝴蝶不菲
只有内嵌css有效,外部css会出现拉伸的情况,所以有两种方案var myCanvas = "<canvas id='myCanvas' width='" + screen.availWidth + "px' height='"+ screen.availHeight + "px'></vanvas>";document.body.insertAdjacentHTML("beforeEnd", myCanvas);或者这种做法var myCanvas = document.createElement("canvas");myCanvas.setAttribute("width", screen.availWidth);myCanvas.setAttribute("height", screen.availHeight);myCanvas.setAttribute("id", "myCanvas");document.body.appendChild(myCanvas);两种方案的共性都是在把元素添加进DOM前设置他的大小