ButtonHover.vue 1.3 KB
Newer Older
hucy's avatar
hucy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<script setup lang="ts"></script>
<template>
  <div class="content fit center">
    <button class="btn">Hover To See Magic</button>
  </div>
</template>

<style lang="scss" scoped>
@keyframes glow {
  from {
    background-position: 0%;
  }
  to {
    background-position: 260%;
  }
}
.content {
  font-family: 'Arial', sans-serif;
  background-color: #100f13;
}
button {
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  box-sizing: border-box;
}
.btn {
  cursor: pointer;
  position: relative;
  padding: 10px 18px;
  font-size: 16px;
  text-transform: uppercase;
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  transition: 0.4s;

  &:hover {
    z-index: 1;
    border-color: transparent;
    background: linear-gradient(
      90deg,
      #fbb454,
      #f7ec09,
      #3ec70b,
      #3b44f6,
      #a149fa,
      #fbb454
    );
    background-size: 260%;
    box-shadow: 0 0 15px rgb(2, 4, 24);
    animation: glow 8s linear forwards;

    &::before {
      opacity: 1;
      z-index: -1;
    }
  }

  &::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: inherit;
    filter: blur(26px);
    opacity: 0;
    transition: 0.4s ease-out;
  }
}
</style>