Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 代码不能正常工作,你能找出问题吗?_Html_Json_Animation_Character Encoding_Bubble Popup - Fatal编程技术网

Html 代码不能正常工作,你能找出问题吗?

Html 代码不能正常工作,你能找出问题吗?,html,json,animation,character-encoding,bubble-popup,Html,Json,Animation,Character Encoding,Bubble Popup,你好,所以我上了在线课程,老师试图教我们一个泡泡动画,就像这样:但更简单的是,他只想让泡泡动画化,但出于某种原因,我的代码不起作用: var numberOfbubbles = 10 for (let i = 0; i < numberOfbubbles; i++) { newBubble() } function newBubble() { let bubble= document.createElement("div");

你好,所以我上了在线课程,老师试图教我们一个泡泡动画,就像这样:但更简单的是,他只想让泡泡动画化,但出于某种原因,我的代码不起作用:

var numberOfbubbles = 10
for (let i = 0; i < numberOfbubbles; i++) {
newBubble()
    }
function newBubble() {
let bubble= document.createElement("div");
                                  bubble.classList.add("bubble");
                                  let x = randomNumber(100);
                                  let delay= randomNumber(3000)
                                  bubble.style.left = x + "vw";
                                  bubble.style.animationDelay = delay + "ms";
                                  document.querySelector("body").appendChild(bubble);
                                  }
                                  function randomNumber() {
                                  return Math.floor(Math.random() * max)
                                  }
                                  ```
the html code has an html:5 standard and just a div so can you tell me where is the problem in my code?,let me know if you want to post something else too
css code: https://codeshare.io/5Nn8PJ
var numberOfbubbles=10
for(设i=0;i
您有多个问题:

1-您的代码没有正确缩进,我会导致错误,下面是一个更可读的代码:

var numberOfbubbles = 10
for (let i = 0; i < numberOfbubbles; i++) {
    newBubble()
}

function newBubble() {
    let bubble= document.createElement("div");
    bubble.classList.add("bubble");

    let x = randomNumber(100);
    let delay= randomNumber(3000)

    bubble.style.left = x + "vw";
    bubble.style.animationDelay = delay + "ms";

    document.querySelector("body").appendChild(bubble);
}

function randomNumber(max) {
    return Math.floor(Math.random() * max)
}
它使脚本在加载其他所有内容后加载并执行 否则,你会试图在身体被接触之前到达它

document.querySelector("body")

4-当您发布问题时,请确保帮助我们了解您所做的,例如,您使用JS,所以请向我们展示您在控制台中的错误

当我检查或查看vs代码时,它没有错误。在随机数上,我在网站上遵循了一个最大公式,所以我必须重写代码或只是添加一些内容以使其正常工作?,我的泡泡只做缩放动画,我必须让它成为多个向左和向上的泡泡,我怎么做?在html中添加了延迟是的。你只需要添加max作为参数,我可以将它设置为我想要的任何值?
document.querySelector("body")