V字形

时间:2017-11-09 13:33:31   收藏:0   阅读:304
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- <script type="text/javascript" src="js/jquery-1.12.1.js"></script> 
 --><title></title>
    <style>
        div {
            width: 50px;
            height: 50px;
            color: white;
            background: red;
            line-height: 50px;
            font-size: 28px;
            font-weight: bold;
            position: absolute;
            text-align: center;
        }
        #div1 {
            position: relative;
        }
    </style>
<script type="text/javascript">
 window.onload = function(){
 var oBtn = document.getElementsByTagName(input)[0],
     conTent = document.getElementById(div1),
     str = ‘‘,
     top,
     left,
    len = 5;
    oBtn.onclick = function () {
         for (var i = 0; i < len; i++) {
          left = i *50 +px;
          if (i<len/2) {
              top = i *50 +px;
          } 
          else {
              top = (len-i -1)*50 +px;
          }
         str +=<div style="top:+top+;left:+left+"> +i+ </div>
     }
          conTent.innerHTML = str;
    }
 }
</script>
</head>
<body>
<input type="button" name="" value="V字形">
<section id="div1"></section>
</body>
</html>

 

原文:http://www.cnblogs.com/zhangli1021/p/7808373.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!