61,126
社区成员
发帖
与我相关
我的任务
分享<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#div1{
width:720px;
padding:0;
}
#div1 div{
background:#66FFCC;
margin:0 0 5px 0;
float:left;
}
</style>
</head>
<body>
<div id="div1"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
<script type="text/javascript">
a=document.getElementById("div1").getElementsByTagName("div")
a[0].style.width="720px"
a[0].style.hight="100px"
for(i=1;i <a.length;i++){
a[i].style.width="350px"
a[i].style.hight="100px"
}
for(i=1;i <a.length;i+=2){
a[i].style.marginRight="20px"
}
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<input type="button" id="add" onclick="addRow()" value="添加"/>
<div id="topDiv" style="width:720px; line-height:25px; border:1px solid #999999;margin:auto; font-size:12px; text-align: center;">this is div one</div>
<div id="loop" style="width:722px; margin:auto; padding-top:2px; height: 100%;">
</div>
</body>
</html>
<script>
var Par = document.getElementById("loop");
function addRow()
{
//左DIV
var boxL = document.createElement("div");
boxL.style.width = "356"+"px";
boxL.style.lineHeight = "25"+"px";
boxL.style.border = "1px solid #999999";
boxL.style.styleFloat = "left";
boxL.style.fontSize = "12";
boxL.style.textAlign = "center";
//右DIV
var boxR = document.createElement("div");
boxR.style.width = "356"+"px";
boxR.style.lineHeight = "25"+"px";
boxR.style.border = "1px solid #999999";
boxR.style.styleFloat = "right";
boxR.style.fontSize = "12";
boxR.style.textAlign = "center";
Par.appendChild(boxR);
Par.appendChild(boxL);
boxL = null;
boxR = null;
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<input type="button" id="add" onclick="addRow()" value="添加"/>
<div id="topDiv" style="width:720px; line-height:25px; border:1px solid #999999;margin:auto; font-size:12px; text-align: center;">this is TOP div </div>
<div id="loop" style="width:722px; margin:auto; padding-top:2px; height: 100%;">
</div>
</body>
</html>
<script>
var Par = document.getElementById("loop");
function addRow()
{
var valL="数据库绑定数据左"; //<%=rs("anclass")%>
var valR="数据库绑定数据右"; //<%=rs("anclass")%>
var divs=2;//自定义循环多少行(两个DIV一行)
for(var i=0;i<divs;i++)
{
//左DIV
var boxL = document.createElement("div");
boxL.style.width = "356"+"px";
boxL.style.lineHeight = "25"+"px";
boxL.style.border = "1px solid #999999";
boxL.style.styleFloat = "left";
boxL.style.fontSize = "12";
boxL.style.textAlign = "center";
//boxL.innerHTML="<font color=red>i'm left DIV</font>";
boxL.innerHTML="<font color=red>"+valL+"</font>";
//右DIV
var boxR = document.createElement("div");
boxR.style.width = "356"+"px";
boxR.style.lineHeight = "25"+"px";
boxR.style.border = "1px solid #999999";
boxR.style.styleFloat = "right";
boxR.style.fontSize = "12";
boxR.style.textAlign = "center";
boxR.innerHTML="<font color=red>"+valR+"</font>";
var blank = document.createElement("div")
blank.style.fontSize="2px";
blank.style.width="720px";
Par.appendChild(boxR);
Par.appendChild(boxL);
Par.appendChild(blank);
boxL = null;
boxR = null;
blank=null;
i=i+1
}
}
</script>