* { margin:0; padding:0; font-family:Microsoft YaHei,serif; } li { list-style:none; } .ball { position:absolute; top:0; left:0; width:100px; height:100px; background:pink; border-radius:50%; }
css改球的大小
球球的个数与速度在这
play(10); function play(num) { //生成num个div for (var i = 0; i < num; i++) { var Div = document.createElement("div"); Div.className = "ball"; Div.leftVal = 3 + i; //速度(水平) Div.topVal = 3 + i; /速度(垂直) Div.style.backgroundColor = randomC(); document.body.appendChild(Div); }