炫酷流光效果,HTML+CSS

学习心得

  1、模糊语法:filter:blur(20px);  此代码直接设置模糊度
  2、设置完background:linear-gradient()   渐变色后 再加上一个background-size, 最后加上个相反的size就能实现颜色的渐变动画。
  3、伪元素 上下左右分别给个-5px,能实现大于本体的一点,效果堪称棒!

CSS

  * {
    margin: 0;
    padding: 0;
  }
  body {
    background-color: #000;
  }
  a {
    text-decoration: none;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    background: linear-gradient(90deg, #03a9f4, #f441a5, #03a9f4);
    background-size: 400%;

    width: 400px;
    height: 100px;
    color: white;
    text-align: center;
    line-height: 100px;
    text-transform: uppercase;
    border-radius: 50px;
  }
  a:hover::before {
    animation: sun 8s infinite;
  }
  a::before {
 content: "";
    position: absolute;
    left: -5px;
    right: -5px;
    top: -5px;
    bottom: -5px;
    /* border: 1px solid red; */
    background: linear-gradient(90deg, #03a9f4, #f441a5, #03a9f4);
    background-size: 400%;
    border-radius: 50px;
    filter: blur(20px);
    z-index: -1;
  }

  @keyframes sun {
    100% {
      background-position: -400% 0;
    }
  }

HTML

HTML一个a标签足以

    <a href="">sunbutton</a>