<分区>
<分区>
我尝试使用 this animation作为背景(实际上只是通过使用 page-warp 在其上放置一些文本)。我知道可以使用 Canvas 作为背景。但是,我已经厌倦了那些但只是为了获得全黑背景。我坐了 2 小时已经尝试解决这个问题,但我什么也没想到。需要一些想法和帮助。
最佳答案
Canvas 在调整大小时自行清除
(element.width 或 element.height 已更改)
当窗口调整大小时绘制。
你可以使用
canvas {
object-fit: contain;
/* object-fit: cover */
}
修复宽高比问题。
关于javascript - 想在这里使用 Canvas 作为背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37227921/
相关文章:
javascript - 单击子链接时将打开 Bootstrap 模式窗口
html - 空白 : pre-wrap not working in IE
javascript - 修复 html 元素而不考虑设备方向和运动
javascript - 未捕获类型错误 : Cannot set property '0' of undefined error
javascript - 这个错误 "Uncaught TypeError: Cannot read property ' style' of undefined” 是什么意思?