标签:获取 htm auto pre for float body relative osi
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>跑马灯</title> <style type="text/css"> *{ margin: 0; padding: 0; } #bian{ width: 300px; height: 300px; margin:0 auto; } .deng{ width: 30px; height: 30px; float: left; position: relative; top: 49%; left: 20%; border-radius:50px; } </style> </head> <body> <div id="bian"> <div class="deng" name="deng"></div> <div class="deng" name="deng"></div> <div class="deng" name="deng"></div> <div class="deng" name="deng"></div> <div class="deng" name="deng"></div> <div class="deng" name="deng"></div> </div> </body> <script type="text/javascript"> //获取所有元素 deng=document.getElementsByName(‘deng‘); bian=document.getElementById(‘bian‘); //设置颜色数组 list=["red","blue","green","yellow","orange","purple"]; //循环给div赋上颜色 for (var i = 0; i < deng.length; i++) { deng[i].style.backgroundColor=list[i]; } //定时器 setInterval(function(){ //把第一个节点插入当前节点的上一个节点之前 bian.insertBefore(deng[0],deng[0].previousSibling); },10); </script> </html>
标签:获取 htm auto pre for float body relative osi
原文地址:http://www.cnblogs.com/zhi-bu/p/7061826.html