Two faint rules frame the link at rest. On hover an accent line runs across the top from the left while the bottom one runs in from the right, a beat behind, so they cross.
Also known as: top and bottom line hover, border top bottom animation, overline hover effect.
<a class="hfx-link-overline-underline" href="#">Our principles</a>
.hfx-link-overline-underline {
--c: var(--hfx-color, #3b82f6);
position: relative;
display: inline-block;
color: var(--c);
font: 600 calc(var(--hfx-size, 16px) * 1.25)/1.3 system-ui, sans-serif;
text-decoration: none;
padding: 0.3em 0.1em;
background:
linear-gradient(color-mix(in srgb, var(--c) 22%, transparent) 0 0) top / 100% 1px no-repeat,
linear-gradient(color-mix(in srgb, var(--c) 22%, transparent) 0 0) bottom / 100% 1px no-repeat;}
.hfx-link-overline-underline::before,
.hfx-link-overline-underline::after {
content: "";
position: absolute;
left: 0;
right: 0;
height: 0.1em;
background: var(--c);
transform: scaleX(0);
transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.hfx-link-overline-underline::before { top: 0; transform-origin: left; }
.hfx-link-overline-underline::after { bottom: 0; transform-origin: right; transition-delay: 0.08s; }
.hfx-link-overline-underline:is(:hover, :focus-visible)::before,
.hfx-link-overline-underline:is(:hover, :focus-visible)::after { transform: scaleX(1); }
@media (prefers-reduced-motion: reduce) {
.hfx-link-overline-underline, .hfx-link-overline-underline *, .hfx-link-overline-underline::before, .hfx-link-overline-underline::after, .hfx-link-overline-underline *::before, .hfx-link-overline-underline *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-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.