canvas 下rem 的应用


var winWidth = window.innerWidth;
var remVal = winWidth / 10;

 

 

<div id="main">
<div class="demo">
<canvas width="10.0rem" height="3.125rem" > </canvas>
</div>
</div>

。。。

var w = canvas.width * remVal,
h = canvas.height * remVal;

。。。

 

var w = canvas.width * remVal,
h = canvas.height * remVal;

canvas.width = w;
canvas.height = h;
canvas.style.backgroundImage = 'url(' + img.src + ')';
canvas.style.backgroundSize = '' + w + 'px ' + h + 'px';
ctx = canvas.getContext('2d');
ctx.fillStyle = 'transparent';
ctx.fillRect(0, 0, w, h);
layer(ctx);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM