简体   繁体   English

如何在Javascript或CSS中实现完整的背景烟雾效果

[英]How can in achieve full background smoke effect in Javascript or CSS

im trying to use this code: 我试图使用此代码:

http://codepen.io/MIML/pen/iBKyC http://codepen.io/MIML/pen/iBKyC

canvas {
    position:absolute;
    margin-left : 50%;
    left: -150px;
}

To put some smoke at the bottom of my page, but im searching how can i put it using 100% width! 在页面底部放些烟,但是我正在搜索如何使用100%宽度放它!

You know, all the bottom of my page, spreads smoke. 您知道,我页面的所有底部都散布着烟雾。

Thanks. 谢谢。

Cool find! 很酷的发现! Usually we don't write code for you, but this one's on me. 通常我们不为您编写代码,但这是在我身上。

First, change the CSS code to this: 首先,将CSS代码更改为:

canvas {
  position: absolute;
  width: 100%; height: 200px;
  bottom: 0px; left: 0px;
}

This will span the canvas across the entire page, but there won't be enough "smoke". 这将跨越整个页面上的画布,但是不会有足够的“烟雾”。

To add more smoke, replace the spawn() function with this! 要添加更多烟雾,请用此替换spawn()函数!

function spawn() {
    if(new Date().getTime() > lastTime + minSpawnTime) {
      lastTime = new Date().getTime();
      parts.push(new smoke(0, emitterY));
      parts.push(new smoke(50, emitterY));
      parts.push(new smoke(100, emitterY));
      parts.push(new smoke(150, emitterY));
      parts.push(new smoke(200, emitterY));
      parts.push(new smoke(250, emitterY));
      parts.push(new smoke(300, emitterY));
    }
}

Hope you enjoy! 希望你喜欢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM