【问题标题】:How to render Vue Components over Html5-canvas如何在 Html5-canvas 上渲染 Vue 组件
【发布时间】:2020-03-27 02:53:19
【问题描述】:

我想用一个 htmlcanvas 作为一个画布作为网页的背景,然后在上面渲染各种 Vuejs 组件。

我确定信息就在那里,我只是不知道要搜索什么。

【问题讨论】:

  • 您可以在画布上显示任意元素,方法是使用position: absolute 在 CSS 中定位它们,您尝试过吗?
  • 不,我没有尝试过,因为我不知道你能做到,谢谢!
  • 在这种情况下任意是什么意思?
  • 我只是指任何元素——Vue,甚至是普通的<div>。我会写一个答案。

标签: javascript html vue.js html5-canvas paperjs


【解决方案1】:

您可以使用带有 position: absolute 的 CSS 设置任何元素的样式,以将元素覆盖在画布顶部。

.container {
  position: relative;
  width: 300px;
  height: 300px;
}

.canvas {
  width: 300px;
  height: 300px;
  background-color: yellow;
}

.overlay {
  position: absolute;
  left: 20px;
  top: 20px;
  width: 100px;
  height: 100px;
  background-color: orange;
}
<div class="container">
  <canvas class="canvas"></canvas>
  <div class="overlay">
    This is displayed on top of the canvas
  </div>
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-19
    • 1970-01-01
    • 1970-01-01
    • 2012-03-23
    • 2013-09-22
    • 2015-07-29
    • 2014-03-13
    • 2012-08-01
    相关资源
    最近更新 更多