【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{width:100%;height:100%;margin:0;overflow:hidden;}

body{background:#000;}

canvas{background:#fff;height:100%;width:100%;}

作者:smile.轉角

QQ:493177502