将元素添加到画布 html5
可以在 HTML5 的画布中添加元素吗?
例如:
<canvas id="canvas2" width="650" height="850">
<div class="draggable" class="ui-widget-content" width='100px' height='100px'>
<textarea class="resizable" rows="2" cols="10" style="color: #FF0707; ">
Example
</textarea>
</div>
</canvas>
这没有显示任何内容...但是,如果我将可拖动的 div 放在 html 中的任何其他元素中,它就可以工作...
我缺少什么?
谢谢。
It is possible to add elements inside HTML5's canvas?
For example:
<canvas id="canvas2" width="650" height="850">
<div class="draggable" class="ui-widget-content" width='100px' height='100px'>
<textarea class="resizable" rows="2" cols="10" style="color: #FF0707; ">
Example
</textarea>
</div>
</canvas>
That doesn't show anything... however, if I put that draggable div inside any other element in the html it works...
What am I missing?
Thx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能像这样将元素添加到画布中。
当浏览器不支持
时,会显示画布的
innerHTML
。您应该在画布旁边添加额外的元素,或者在画布上方添加一个
层。
参见:
https://developer.mozilla.org/en/Canvas_tutorial/Basic_usage#Fallback_content
You cannot add elements into the canvas like that.
The
innerHTML
of the canvas is shown when a browser does not suport<canvas>
.You should extra elements beside the canvas, or a
<div>
layer above the canvas.See also:
https://developer.mozilla.org/en/Canvas_tutorial/Basic_usage#Fallback_content
画布元素被替换元素。他们渲染位图。它们的内容(如
和
的内容)供不支持该元素时使用。
您想要做的事情类似于将元素放入图像中。
— http://www.w3.org/ TR/html5/the-canvas-element.html#the-canvas-element
Canvas elements are replaced elements. They render a bitmap. Their content, like that of
<iframe>
s and<object>
s is for use when the element is not supported.What you are trying to do is akin to putting elements inside an image.
— http://www.w3.org/TR/html5/the-canvas-element.html#the-canvas-element