day03--利用for循环做来一个小V字形(小练习)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/itzhengmaolin/article/details/54353510
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
div{
width: 50px;
height: 50px;
background-color: red;
position: absolute;
top: 0;
left: 0;
line-height: 50px;
text-align: center;
}
</style>

<script type="text/javascript">
  window.οnlοad=function (){
for(var i=0;i<11;i++){
document.body.innerHTML+='<div>'+i+'</div>';
}
var aDiv=document.getElementsByTagName("div");
for(var j=0;j<6;j++){
aDiv[j].style.left=j*50+'px';
aDiv[j].style.top=j*50+'px';
}
for(var z=6;z<11;z++){
aDiv[z].style.left=z*50+'px';
aDiv[z].style.top=(10-z)*50+'px';
}
}
 
</script>

</head>
<body>
</body>

</html>



展开阅读全文

没有更多推荐了,返回首页