循环发光的边框动画

by jkhaoqi110

HTML

<li class="option highlight">
  <div class="sell-helper">76% of Pros choose Yearly</div>
  <p class="option-name">Yearly</p>
  <div>
    <p class="price"><span>$15</span>/month</p>
    <p class="frequency">Billed <span>$180</span> yearly</p>
  </div>
</li>

CSS

body {
    background: rgb(37, 37, 40);
}

.option {
  border-radius: 20px;
  background: rgba(0, 0, 0, .4);
  display: flex;
  flex-direction: column;
  flex: 1;
  box-sizing: border-box;
  padding: 55px 35px;
  padding-top: 75px;
  max-width: 360px;
  position: relative;
  text-align: center;
  margin: 30px auto;
  color: white;
}

.option.highlight {
  box-shadow: rgba(28, 205, 219, 0.09) 0 0 20px;
}

@property --angle {
  syntax: '<angle>';
  /* <- defined as type number for the transition to work */
  initial-value: 0deg;
  inherits: false;
}

@keyframes rotate {
  to {
    --angle: 360deg;
  }
}

.option.highlight:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 20px;
  border: 2px solid transparent;
  background: linear-gradient(45deg, purple, orange) border-box;
  background-image: linear-gradient(135deg, #2AF598, #009EFD 50%, #2AF598);
  -webkit-mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;

  pointer-events: none;

  background-image: linear-gradient(var(--angle), rgba(255, 255, 255, 0.28), #00FBFD 50%, rgba(255, 255, 255, 0.28));
  background-image: conic-gradient(from var(--angle) at 50% 50%, rgba(255, 255, 255, 0.2) 39%, #00FBFD 50%, rgba(255, 255, 255, 0.2) 61%);

  animation: 5s rotate linear infinite running;
}