zoukankan      html  css  js  c++  java
  • V形

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    </head>
    <style>
    #div1{position:relative;}
    #div1 div{50px;height:50px;background:blue;color:#fff;font-size:20px;text-align:center;line-height:50px;position:absolute;}
    </style>
    <script>
    window.onload = function()
    {

    var oTxt = document.getElementById('txt1');
    var oBtn = document.getElementById('btn1');
    var oDiv = document.getElementById('div1');

    oBtn.onclick = function()
    {
    //0 0*50
    //1 1*50
    //2 2*50
    //3 1*50
    //4 0*50
    for( var i=0;i<5;i++ )
    {
    if( i<2 )
    {
    oDiv.innerHTML +='<div style="left:'+(i*50)+'px;top:'+(i*50)+'px;">'+i+'</div>';
    }
    else
    {
    oDiv.innerHTML +='<div style="left:'+(i*50)+'px;top:'+((5-1-i)*50)+'px;">'+i+'</div>';
    };
    };

    };

    };
    </script>

    <body>
    <input type="text" value="" id="txt1"> <input type="button" id="btn1" value="按钮">

    <div id="div1">

    </div>


    </body>
    </html>

  • 相关阅读:
    网络
    分区
    JavaScript概述
    CSS样式属性
    css选择器
    CSS的引入方式
    css介绍
    HTML结构
    常用标签
    HTML介绍
  • 原文地址:https://www.cnblogs.com/gyc51/p/8328134.html
Copyright © 2011-2022 走看看