<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
padding:0px;
margin:0px;
}
.box{
width: 200px;
height: 200px;
background: blue;
position: absolute;
left:0px
}
.box2{
background: red;
margin-top: 210px;
}
</style>
</head>
<body>
<!-- 盒子移动动画 -->
<div class="box box1"></div>
<div class="box box2"></div>
<script type="text/javascript">
var box1 = document.querySelector('.box1');
var box2 = document.querySelector('.box2');
//匀速运动 分装上面的代码块设计一个匀速运动的函数
function move(obj,target){
obj.myInter = setInterval(function(){
var offsetLeft = obj.offsetLeft;
// console.log(offsetLeft);
var num = 10;//每次都移动10个像
JavaScript盒子移动
于 2022-07-05 18:51:46 首次发布