首页 > 解决方案 > 如何在 html 中使用 paper.js 作为背景

问题描述

我正在尝试将“星星”示例用作 html 页面中的简单背景,页面上也包含 html 内容(我远未进入 js。简单的 html 和 css 处理是可以的)。

我必须放入什么: - css(单独或内联) - html 头 - html 正文

我只是在研究 .js 用作背景。我设法将鼠标参数作为定义星星代码的矢量。现在运行正常,但我要么只显示 .js 或缺少星星背景的 html 内容。提前非常感谢!

标签: paperjs

解决方案


这是我在我的 CSS 中设置的

body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

canvas {
    margin: 0px;
    padding: 0px;
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
}

希望这可以帮助


推荐阅读