码迷,mamicode.com
首页 > 其他好文 > 详细

V字形

时间:2017-11-09 14:27:27      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:text   for   window   ++   str   width   idt   pos   title   

<!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>

 

V字形

标签:text   for   window   ++   str   width   idt   pos   title   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!