Skip to content

CSS渐变边框动画 #65

@varHarrie

Description

@varHarrie
<template>
  <div class="wrapper">
    <h3>Animated Gradient Border</h3>

    <div class="card one">
      Style 1
    </div>

    <div class="card two">
      Style 2
    </div>
  </div>
</template>

<style>
@keyframes border {
  100% {
    --border-angle: 360deg;
  }
}

@property --border-angle {
  inherits: false;
  initial-value: 0deg;
  syntax: '<angle>';
}

.wrapper {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
}

.title {
  
}

.card {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  width: 300px;
  height: 150px;
  border: 1px solid transparent;
  border-radius: 8px;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px;
  animation: border 5s linear infinite;
  box-sizing: border-box;
}

.one {
  background:
    linear-gradient(white,white) padding-box,
    conic-gradient(from var(--border-angle),#eee 80%, #6366f1 86%, #a5b4fc 90%, #6366f1 94%, #eee) border-box;
}

.two {
  background:
    linear-gradient(white, white) padding-box,
    linear-gradient(var(--border-angle), #6366f1, #a855f7, white, #a855f7, #ec4899) border-box border-box;
}
</style>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions