#d2
{
width: 100px;
color: yellow;
height: 100px;
border: 1px solid;
position: absolute;left: 0px; top: 0px;
background-color: #000000;
text-align: center;
font-size: 35px;
font-weight: bolder;
}
#d1
{
width: 100px;
height: 100px;
border: 1px solid;
margin-top: 100px;
margin-left: 50px;
}
flag=true;
x=0
function fun1()
{
var input = document.getElementsByTagName("input")[0];
var div1=document.getElementsByTagName("div")[0];
if(x>=innerWidth-div1.offsetWidth)
{
flag=false;
}
else if(x<=0)
{
flag=true;
}
if(flag)
{
x=x+80
}
else
{
x=x-80
}
div1.style.left=x+"px"
}
动次打次