A pastel foil border whose colors slide as if the card were tilting under a light, with a white sheen crossing the other way. Two background layers ease back and forth on alternate loops.
Also known as: iridescent border css, holo foil border, holographic gradient border.
<div class="bdr-holographic-border">Holographic</div>
.bdr-holographic-border {
--c: var(--bdr-color, #3b82f6);
font-size: var(--bdr-size, 16px);
position: relative;
display: grid;
place-items: center;
width: 15em;
height: 8.5em;
border-radius: 1em;
font-family: system-ui, sans-serif;
font-weight: 600;
background: color-mix(in srgb, var(--c) 8%, #0d0f16);
color: #f8fafc;
}
.bdr-holographic-border::before,
.bdr-holographic-border::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
background:
linear-gradient(115deg, transparent 38%, rgb(255 255 255 / 0.9) 50%, transparent 62%) 100% 0 / 300% 100% no-repeat,
linear-gradient(60deg, #f9a8d4, color-mix(in srgb, var(--c) 45%, #fff), #6ee7b7, #fde047, #c4b5fd, #f0abfc, #f9a8d4) 0 0 / 300% 300%;
pointer-events: none;
animation: bdr-holographic-border-tilt 4s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
.bdr-holographic-border::before {
padding: 0.3em;
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.bdr-holographic-border::after { opacity: 0.12; }
@keyframes bdr-holographic-border-tilt {
from { background-position: 100% 0, 0% 0%; }
to { background-position: 0% 0, 100% 100%; }
}
@media (prefers-reduced-motion: reduce) {
.bdr-holographic-border, .bdr-holographic-border *, .bdr-holographic-border::before, .bdr-holographic-border::after, .bdr-holographic-border *::before, .bdr-holographic-border *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--bdr-color on the element or a parent.
Currently previewing #3b82f6.--bdr-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.