html5 div scroll,html - html5 canvas scroll - Stack Overflow

本文探讨了一位开发者尝试通过JavaScript动态创建Canvas元素,并在其中进行绘图,然后将Canvas放入Marquee元素以实现滚动效果的问题。虽然代码成功创建了Canvas并进行了绘图,但Marquee的滚动并未正常工作。问题可能在于Marquee与Canvas的结合方式。这是一个关于前端开发,特别是JavaScript、HTML和Canvas技术的实际应用案例。
摘要由CSDN通过智能技术生成

i have a requirement that I need to create a canvas and draw inside it programattically and put it inside a marquee, all these through javascript. Is it possible ? a few pointers please

As a follow-up: i wrote the following, it creates the canvas but does not scrolll it, but the hard coded marquee works !

you are welcome

function btnClicked()

{

alert('here');

var canvas = document.createElement('canvas');

context = canvas.getContext('2d');

// Draw whatever on your canvas

context.beginPath();

context.moveTo(70, 140);

context.lineTo(140, 70);

context.stroke();

var div = document.createElement('div');

div.appendChild(canvas);

var marquee = document.createElement('marquee');

marquee.appendChild(div);

document.body.appendChild(marquee);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值