用JS编写,实现导航条的动画效果

img


<!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <title> 页面名称 </title>
  <style type="text/css">
    .box {
      height: 200px;
      width: 200px;
      background-color: green;
      margin-top: 100px;
      cursor: pointer;
      transition: all 0.7s;
    }


    /* hover鼠标移上去后的样式 */
    .box:hover {
      /* 沿着y轴往上移50px */
      transform: translateY(-50px);
    }
  </style>
</head>

<body>
  <div class="box">

  </div>
</body>

</html>