SOURCE

console 命令行工具 X clear

                    
>
console
const parent = document.querySelector('.parent');
const son = document.querySelector('.son');
const btn = document.querySelector('.btn');

// 下面是看效果的代码,请忽略
btn.onclick = function () {
  parent.style.display = 'block';
  parent.onanimationend = function(){
    parent.style.display = 'none';
  }
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="./index.css">
  
</head>

<body>
  <div class="wrapper">
    <div class="car">购物车</div>
    <button class="btn">点击查看纵向移动</button>
    <div class="ball parent" style="--left:200px;--top:100px; --y: 350px">
      <span class="son">+</span>
    </div>
  </div>
  <script src="./index.js"></script>
</body>
</html>
* {
  margin: 0;
  padding: 0;
  text-align: center;
}

html, body {
  height: 100%;
}

:root {
  --carSize: 70px;
  --ballSize: 30px;
  --btnSize: 100px;
  --color: rgb(91, 167, 229)
}

.wrapper {
  width: 375px;
  height: calc(100% - 20px);
  border: 1px solid;
  position: relative;
  box-sizing: border-box;
  margin: 10px;
}

.car {
  width: var(--carSize);
  height: var(--carSize);
  border-radius: 50%;
  background-color: var(--color);
  position: fixed;
  bottom: 30px;
  left: 30px;
  font-size: 12px;
  line-height: var(--carSize);
  color: white;
}

.btn {
  width: var(--btnSize);
  height: calc(var(--btnSize) / 2);
  background-color: var(--color);
  border-radius: 3px;
  color: white;
  outline: none;
  border: none;
  position: absolute;
  right: 20px;
  top: 100px;
}

.ball {
  left: var(--left);
  top: var(--top);
  width: var(--ballSize);
  height: var(--ballSize);
  border: 1px solid;
  border-radius: 50%;
  position: absolute;
}
.ball span {
  display: block;
  width: var(--ballSize);
  height: var(--ballSize);
  border-radius: 50%;
  background-color: var(--color);
  font-size: 20px;
  line-height: calc(var(--ballSize) - 4px);
  font-weight: 700;
  color: white;
  transform: translateX(var(--translateX));
}



@keyframes moveY {
  to {
    transform: translateY(var(--y));
  }
}


.ball {
  animation: moveY 1s;
  animation-timing-function: cubic-bezier(0.5,-0.5,1,1);
}








/* 展示效果用,请忽略 */
.ball{
  display: none;
}