前端开发

七夕小礼包派送~动态比心

2021-01-13 19:45:08 阅读数 1182 收藏 0

(效果图)

 

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>xinxin</title></head><body> </body><script src="../../public.js"></script><script> setInterval(autoPlay,250); function autoPlay(){ var img = document.createElement("img"); img.src = "xin.png"; document.body.appendChild(img); var w = getRand(10,30); img.style.width = w + "px"; img.style.position = "absolute"; var l = getRand(0,window.innerWidth-w);//距离左边 var t = getRand(0,window.innerHeight-w);//距离上面 img.style.left = l + "px"; img.style.top = t + "px"; }</script></html>