The same drawn underline, but it grows outward from the middle. Only the transform origin changes, which makes it a good companion to the left-to-right version.
Also known as: center out underline, expanding underline.
<a class="hfx-link-underline-center" href="#">Our story</a>
.hfx-link-underline-center {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
position: relative;
display: inline-block;
color: var(--c);
font: 600 1em system-ui, sans-serif;
text-decoration: none;
}
.hfx-link-underline-center::after {
content: "";
position: absolute;
left: 0;
bottom: -0.15em;
width: 100%;
height: 2px;
background: var(--c);
transform: scaleX(0);
transform-origin: center;
transition: transform 0.3s ease;
}
.hfx-link-underline-center:hover::after { transform: scaleX(1); }
@media (prefers-reduced-motion: reduce) {
.hfx-link-underline-center, .hfx-link-underline-center *, .hfx-link-underline-center::before, .hfx-link-underline-center::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.