【html5】如何让Canvas标签自适应设备

javascript方法:

var oC=document.querySelectorAll('canvas')[0];
oC.width=document.documentElement.clientWidth;
oC.height=document.documentElement.clientHeight;
//oC.width=window.innerWidth;
//oC.height=window.innerHeight;

css方法:

html,body{100%;height:100%;margin:0;overflow:hidden;}
body{background:#000;}
canvas{background:#fff;height:100%;100%;}

作者:smile.轉角

QQ:493177502

原文地址:https://www.cnblogs.com/websmile/p/5292392.html