3D Rolling Typo & Magic Icon
Letters roll in 3D cascade while the icon performs a 360° neon revolution.
Live demo
Hover the buttons to see the effect.
How to use this effect
Paste the HTML into your page and the CSS into your stylesheet. Change --btn-color, --btn-bg and --anim-speed to match your design.
<button class="hover-btn btn-size-md btn-hover-rolling-magic">
<span class="btn-rolling-text">
<span class="btn-rolling-line original"><span class="btn-rolling-char" style="--char-i: 0">H</span><span class="btn-rolling-char" style="--char-i: 1">o</span><span class="btn-rolling-char" style="--char-i: 2">v</span><span class="btn-rolling-char" style="--char-i: 3">e</span><span class="btn-rolling-char" style="--char-i: 4">r</span><span class="btn-rolling-char" style="--char-i: 5">L</span><span class="btn-rolling-char" style="--char-i: 6">a</span><span class="btn-rolling-char" style="--char-i: 7">b</span></span>
<span class="btn-rolling-line duplicate" aria-hidden="true"><span class="btn-rolling-char" style="--char-i: 0">H</span><span class="btn-rolling-char" style="--char-i: 1">o</span><span class="btn-rolling-char" style="--char-i: 2">v</span><span class="btn-rolling-char" style="--char-i: 3">e</span><span class="btn-rolling-char" style="--char-i: 4">r</span><span class="btn-rolling-char" style="--char-i: 5">L</span><span class="btn-rolling-char" style="--char-i: 6">a</span><span class="btn-rolling-char" style="--char-i: 7">b</span></span>
</span>
<svg class="btn-icon btn-icon-right" width="18" height="18" viewBox="0 0 256 256" fill="currentColor"><path d="M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"></path></svg>
</button>
/* ==========================================
HoverLab Effect #21: 21. 3D Rolling Typo & Magic Icon
Self-Contained & Plug-and-Play CSS
========================================== */
:root {
--btn-color: #e6332a;
--btn-bg: #eeeeee;
--anim-speed: 0.35s;
}
/* Base Button Styles */
.hover-btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 10px;
padding: 12px 28px;
font-family: inherit;
font-size: 15px;
font-weight: 500;
letter-spacing: -0.01em;
white-space: nowrap;
cursor: pointer;
background-color: transparent;
color: var(--btn-color, #e6332a);
border: 1.5px solid var(--btn-color, #e6332a);
border-radius: 9999px;
text-decoration: none;
user-select: none;
transition: all var(--anim-speed, 0.35s) cubic-bezier(0.16, 1, 0.3, 1);
box-sizing: border-box;
}
.hover-btn.btn-icon-only {
padding: 0 !important;
aspect-ratio: 1 / 1;
width: 44px;
height: 44px;
}
.hover-btn .btn-icon {
display: block;
flex-shrink: 0;
transition: transform var(--anim-speed, 0.35s) cubic-bezier(0.16, 1, 0.3, 1);
}
/* Effect Styles */
.btn-hover-rolling-magic {
position: relative;
overflow: hidden;
transition: transform var(--anim-speed, 0.25s) ease,
background-color var(--anim-speed, 0.3s) ease,
border-color var(--anim-speed, 0.3s) ease,
box-shadow var(--anim-speed, 0.35s) ease;
}
.btn-hover-rolling-magic:hover {
transform: translateY(-2px);
background-color: #18181b0d;
box-shadow: 0 4px 20px #18181b14;
}
.canvas-dark .btn-hover-rolling-magic:hover {
background-color: #ffffff14;
box-shadow: 0 4px 25px #ffffff1f;
}
.btn-hover-rolling-magic .btn-icon {
position: relative;
z-index: 2;
transition: transform var(--anim-speed, 0.6s) cubic-bezier(0.34, 1.56, 0.64, 1), filter var(--anim-speed, 0.4s) ease;
}
.btn-hover-rolling-magic:hover .btn-icon {
transform: translateX(4px) rotate(360deg) scale(1.25);
filter: drop-shadow(0 0 8px var(--btn-color, #18181b));
}
.btn-rolling-text {
position: relative;
display: inline-block;
overflow: hidden;
line-height: 1.2;
vertical-align: middle;
}
.btn-rolling-line {
display: inline-flex;
white-space: pre;
}
.btn-rolling-line.duplicate {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.btn-rolling-char {
display: inline-block;
transition: transform var(--anim-speed, 0.45s) cubic-bezier(0.34, 1.56, 0.64, 1),
opacity var(--anim-speed, 0.3s) ease;
transition-delay: calc(var(--char-i) * (var(--anim-speed, 0.35s) * 0.1));
transform-origin: 50% 100%;
backface-visibility: hidden;
}
.btn-rolling-line.original .btn-rolling-char {
transform: translateY(0) rotateX(0);
opacity: 1;
}
.btn-rolling-line.duplicate .btn-rolling-char {
transform: translateY(120%) rotateX(-90deg);
opacity: 0;
}
.btn-hover-rolling-magic:hover .btn-rolling-line.original .btn-rolling-char {
transform: translateY(-120%) rotateX(90deg);
opacity: 0;
}
.btn-hover-rolling-magic:hover .btn-rolling-line.duplicate .btn-rolling-char {
transform: translateY(0) rotateX(0);
opacity: 1;
}
When to use it
Motion effects move the button or its content. A small displacement makes the target feel physical and clickable. Use them on playful interfaces, landing pages and icon buttons, and keep the travel short.
Accessibility
Use a real <button> or <a> element so the effect also works with the keyboard: duplicate the :hover selectors with :focus-visible. For visitors who prefer less motion, wrap the transitions and animations in @media (prefers-reduced-motion: no-preference).
Browser support
The effect relies on standard CSS (transitions, transforms, pseudo-elements and custom properties). It works in current versions of Chrome, Edge, Firefox and Safari, with no JavaScript and no dependency.