Skip to content

Instantly share code, notes, and snippets.

@smaje99
Last active March 31, 2024 04:52
Show Gist options
  • Select an option

  • Save smaje99/1fb694068caa674ffc0244d9bc23c86c to your computer and use it in GitHub Desktop.

Select an option

Save smaje99/1fb694068caa674ffc0244d9bc23c86c to your computer and use it in GitHub Desktop.
Button with animated gradient border
<button>smaje.dev</button>
<button class="fill">smaje.dev</button>
:root {
background-color: black;
}
button {
--timing: linear(0, 0.3, 0.75, 1);
--colors: indigo, purple, hotpink;
font-family: 'Open Sans' sans-serif;
font-size: 1.5rem;
display: block;
padding: 1rem 2rem;
margin: 3rem;
background: none;
color: #fff;
/* border-image-source solo soporta una imagen */
border-image-source: conic-gradient(from var(--angle), var(--colors));
border-image-slice: 1 1 1 1;
border-image-width: 0.3rem;
animation: move 1s infinite var(--timing);
transition: background 750ms;
box-shadow: 5px 5px 0 #0006;
&.fill {
border-image-slice: 1 1 1 1 fill;
}
&:active {
transform: translate(5px, 5px);
box-shadow: none;
}
}
@keyframes move {
from { --angle: 0deg; }
to { --angle: 360deg; }
}
@property --angle {
syntax: "<angle>";
inherits: true;
initial-value: 0deg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment