123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <template>
- <div class="hc-border-neon" :class="[isAlign, isNeon ? 'is-neon':'']">
- <i class="top"/>
- <i class="bottom"/>
- <i class="left"/>
- <i class="right"/>
- </div>
- </template>
- <script setup>
- import {ref, watch} from "vue";
- const props = defineProps({
- align: {
- type: String,
- default: 'left'
- },
- neon: {
- type: Boolean,
- default: false
- },
- })
- const isAlign = ref(props.align)
- const isNeon = ref(props.neon)
- //监听
- watch(() => [
- props.align,
- props.neon,
- ], ([val, neon]) => {
- isAlign.value = val
- isNeon.value = neon
- })
- </script>
- <style lang="scss">
- html.dark {
- .hc-border-neon {
- position: absolute;
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- border-radius: inherit;
- overflow: hidden;
- i.top {
- position: absolute;
- top: 0;
- right: -100%;
- height: 2px;
- width: 100%;
- background-image: linear-gradient(
- 270deg,
- transparent,
- #03e9f4,
- transparent
- );
- }
- i.bottom {
- position: absolute;
- bottom: 0;
- left: -100%;
- height: 2px;
- width: 100%;
- background-image: linear-gradient(
- 270deg,
- transparent,
- #03e9f4,
- transparent
- );
- }
- i.left {
- position: absolute;
- width: 2px;
- height: 100%;
- top: -100%;
- left: 0;
- background-image: linear-gradient(
- 0deg,
- transparent,
- #03e9f4,
- transparent
- );
- }
- i.right {
- position: absolute;
- width: 2px;
- height: 100%;
- bottom: -100%;
- right: 0;
- background-image: linear-gradient(
- 360deg,
- transparent,
- #03e9f4,
- transparent
- );
- }
- &.left {
- i.left {
- animation: hc-border-neon-two 4s linear 1s infinite;
- }
- i.bottom {
- animation: hc-border-neon-one 4s linear 2s infinite;
- }
- i.right {
- animation: hc-border-neon-four 4s linear 3s infinite;
- }
- i.top {
- animation: hc-border-neon-three 4s linear infinite;
- }
- &.is-neon {
- i.left {
- bottom: -100%;
- right: initial;
- top: initial;
- left: 0;
- animation: hc-border-neon-four 4s linear 1s infinite;
- }
- i.top {
- left: 0;
- right: initial;
- bottom: initial;
- animation: hc-border-neon-one 4s linear 2s infinite;
- }
- i.right {
- top: 0;
- bottom: initial;
- animation: hc-border-neon-two 4s linear 3s infinite;
- }
- i.bottom {
- bottom: 0;
- left: initial;
- right: -100%;
- animation: hc-border-neon-three 4s linear infinite;
- }
- }
- }
- &.right {
- i.right {
- animation: hc-border-neon-four 4s linear 1s infinite;
- }
- i.top {
- animation: hc-border-neon-three 4s linear 2s infinite;
- }
- i.left {
- animation: hc-border-neon-two 4s linear 3s infinite;
- }
- i.bottom {
- animation: hc-border-neon-one 4s linear infinite;
- }
- &.is-neon {
- i.left {
- bottom: -100%;
- right: initial;
- top: initial;
- left: 0;
- animation: hc-border-neon-four 4s linear 3s infinite;
- }
- i.right {
- top: 0;
- bottom: initial;
- animation: hc-border-neon-two 4s linear 1s infinite;
- }
- i.top {
- left: 0;
- right: initial;
- bottom: initial;
- animation: hc-border-neon-one 4s linear infinite;
- }
- i.bottom {
- bottom: 0;
- left: initial;
- right: -100%;
- animation: hc-border-neon-three 4s linear 2s infinite;
- }
- }
- }
- }
- }
- @keyframes hc-border-neon-one {
- 0% {
- left: -100%;
- }
- 50%,
- 100% {
- left: 100%;
- }
- }
- @keyframes hc-border-neon-two {
- 0% {
- top: -100%;
- }
- 50%,
- 100% {
- top: 100%;
- }
- }
- @keyframes hc-border-neon-three {
- 0% {
- right: -100%;
- }
- 50%,
- 100% {
- right: 100%;
- }
- }
- @keyframes hc-border-neon-four {
- 0% {
- bottom: -100%;
- }
- 50%,
- 100% {
- bottom: 100%;
- }
- }
- </style>
|