最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can canvas tag be used to draw on top of other items on a page? - Stack Overflow

programmeradmin2浏览0评论

Can an HTML canvas tag be positioned over other html content on a page? For example, will something the following CSS declaration make a canvas tag do what I expect it to?

canvas.mycanvas {
  position: absolute;
  background: transparent;
  z-index: 10;
  top: 10px; left: 10px;
}

Can an HTML canvas tag be positioned over other html content on a page? For example, will something the following CSS declaration make a canvas tag do what I expect it to?

canvas.mycanvas {
  position: absolute;
  background: transparent;
  z-index: 10;
  top: 10px; left: 10px;
}
Share Improve this question asked Feb 19, 2009 at 17:11 DevonDevon 5,7845 gold badges40 silver badges46 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

That should work perfectly. There's no need to set the background to 'transparent' though.

Overlaying a canvas is how this bookmarklet works.

Yes, this works fine in canvas-supporting browsers, and furthermore works equally as well in IE6 and IE7 using the exCanvas project which translate canvas mands into Microsoft's XML-based vector language, VML.

One thing I noticed when attempting to overlay canvas elements across-browsers is that you have to be especially careful with the order in which you append and subsequently access any canvas child DOM nodes. IE needs the item to be appended before you can work with it.

have you tried it? is it not working? i would say that the canvas tag would act as any other tag and be positioned aproprietly. if you want an easy way to test it in firefox, go here http://www.w3schools./tags/tryit.asp?filename=tryhtml5_canvas

发布评论

评论列表(0)

  1. 暂无评论