Hover: Record the instructor’s instruction to make a hover style effect (like this)

And here’s how it works.

The code is as follows!

<! DOCTYPEhtml>

<html>
  <head>
    <meta charset="utf-8">
    <title>hover</title>

    <style>
      body {
        background-color: #e1332d;
      }

      .box {
        /* * * */
        position: relative;
        overflow: hidden;
        width: 170px;
        height: 50px;
        border: 1px solid #fff;
        color: #fff;
        text-align: center;
        line-height: 50px;
      }


      .box::before {
        content: ' ';
        /* Absolute position does not occupy the position */
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
>         /* Make highlights */
>         background-image: linear-gradient(>90deg,
>           rgba(255.255.255.0),
>           rgba(255.255.255.5),
>           rgba(255.255.255.0));
        /* Move 100% of your width to the left with Overflow: Hidden */
        /* Tilt the box */
        transform: translateX(-100%) skew(-45deg);
      }


      .box:hover::before {
        transform: translateX(100%) skew(-45deg);
        transition: all .3s;
      }

    </style>

  </head>
  <body>
    <div class="box">HOVER</div>
  </body>
</html>
Copy the code

Note that the box needs to be tilted or it will look like a big white rat running through it

Both ends of the gradient are white and the opacity is 0