SOURCE

console 命令行工具 X clear

                    
>
console
let timer = setTimeout(function() {
  let ele = document.getElementById('box')
  ele.setAttribute('class', 'right' )
}, 500)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Document</title>
</head>
<body>
  <div id="box"></div>
</body>
</html>
* {
margin: 0;
padding: 0;
}

div {
  width: 200px;
  height: 200px;
  margin-left: 0;
  background-color: red;
  transition: all 3s ease-in-out 0s;
  -webkit-transition: all 3s ease-in-out 0s;
}
.right {
  margin-left: 400px;
  background-color: blue;
}