AI CSS Animations

Marquee That Pauses on Hover

A strip of tag pills scrolls sideways and freezes the moment the pointer lands on it, so any pill can be read or clicked. One line does it: animation-play-state: paused on :hover.

Also known as: pause marquee on hover css, tag marquee, hover to stop scrolling text.

#design#motion#css#typography#ui#branding

HTML

<div class="txt-marquee-pause-on-hover">
  <div class="txt-marquee-pause-on-hover-group">
    <span>#design</span><span>#motion</span><span>#css</span><span>#typography</span><span>#ui</span><span>#branding</span>
  </div>
  <div class="txt-marquee-pause-on-hover-group" aria-hidden="true">
    <span>#design</span><span>#motion</span><span>#css</span><span>#typography</span><span>#ui</span><span>#branding</span>
  </div>
</div>

CSS

.txt-marquee-pause-on-hover {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 0.72);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  display: flex;
  width: 19em;
  padding: 0.4em 0;
  overflow: hidden;
  white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);}
.txt-marquee-pause-on-hover-group {
  display: flex;
  flex-shrink: 0;
  gap: 0.5em;
  padding-right: 0.5em;
  animation: txt-marquee-pause-on-hover-scroll 14s linear infinite;
}
.txt-marquee-pause-on-hover:hover .txt-marquee-pause-on-hover-group {
  animation-play-state: paused;
}
.txt-marquee-pause-on-hover-group span {
  padding: 0.35em 0.85em;
  border-radius: 2em;
  font-weight: 600;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent);
  transition: color 0.25s, background-color 0.25s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.txt-marquee-pause-on-hover-group span:hover {
  color: #fff;
  background: var(--c);
  transform: translateY(-0.12em);
}
@keyframes txt-marquee-pause-on-hover-scroll {
  to { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-marquee-pause-on-hover, .txt-marquee-pause-on-hover *, .txt-marquee-pause-on-hover::before, .txt-marquee-pause-on-hover::after, .txt-marquee-pause-on-hover *::before, .txt-marquee-pause-on-hover *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar text animations