zoukankan      html  css  js  c++  java
  • for循环坐标生成《逢十往下一行》

    <!DOCTYPE html>  

       <meta charset="UTF-8">

        <title></title>

        <style type="text/css">

          div{    50px;  

          height: 50px;   

         background-color: red;

          position: absolute;  

         top: 0;   left: 0;  

         line-height: 50px;

          text-align: center;  

         }

      </style>

      <script type="text/javascript">  

       window.onload=function (){

        // 1、先创建div   

         for(var i=0;i<20;i++){    

           document.body.innerHTML=document.body.innerHTML+'<div>'+i+'</div>';   

         }     

       // 2 、再查找div的位置   

         var aDiv = document.getElementsByTagName('div');

           for(var i=0;i<10;i++){     

             aDiv[i].style.left=20+i*50+'px';   

         }      

        // 3 、位置稍微做调整    

        // aDiv[10].style.top=50+'px';  

         // aDiv[10].style.left=20+'px';    //

         // aDiv[11].style.top=50+'px';  

        // aDiv[10].style.left=20+50*(11-10)+'px';   

         for(var i=10;i<30;i++){  

           aDiv[i].style.left=20+(i-10)*50+'px';   

          aDiv[i].style.top=50+'px';   

         }  

       }   

    </script>

     </head>

     <body>  

     </body>

    </html>

  • 相关阅读:
    Protobuf, understand the hood
    Linux下Matlab崩溃的解决方法
    高德地图AMapUI is not defined
    微信小程序
    js字符数组转化为数字数组
    高德地图网页端js API
    es6 函数的扩展(尾递归看不太懂,不浪费时间了)
    es6 数值扩展(正则稍微看了下,以后用得着再细看)
    vue清空表单
    es6 变量的解析复制
  • 原文地址:https://www.cnblogs.com/xuling123/p/6902875.html
Copyright © 2011-2022 走看看