<!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.onload=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>
<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.onload=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>
本文提供了一个使用HTML、CSS及JavaScript实现简单页面布局的例子,通过动态生成红色方块并调整其位置,展示了基本的网页制作技巧。
516

被折叠的 条评论
为什么被折叠?



