# 随机位置随机颜色的点 <script> setInterval(function() { var dot = document.createElement("div"); dot.style.position = "fixed"; dot.style.top = Math.random() * 100 + "%"; dot.style.left = Math.random() * 100 + "%"; dot.style.width = "10px"; dot.style.height = "10px"; dot.style.borderRadius = "50%"; dot.style.backgroundColor = "#" + Math.floor(Math.random()*16777215).toString(16); document.body.appendChild(dot); }, 1000); </script> # 元素跳动 <style> @keyframes jump { 0% { transform: translateY(0); } 50% { transform: translateY(-20px); } 100% { transform: translateY(0); } } .jump-element { animation: jump 1s infinite; } </style>
标签:style,代码,random,transform,jump,dot,有趣,前端,Math From: https://www.cnblogs.com/lytcreate/p/17835750.html