AI CSS Animations

Slide Aside Image Hover

The photo covers the whole card, then slides right on hover to uncover a title, a line of copy and a link that follow it in with a stagger. The text panel sits behind the photo all along.

Also known as: image slides to reveal text, push image hover, hidden text behind image.

Hut to hut

Six days on the high route with one pack.

Read story
Make this your own with AI

HTML

<article class="hfx-image-slide-aside">
  <div class="hfx-image-slide-aside-text">
    <strong>Hut to hut</strong>
    <p>Six days on the high route with one pack.</p>
    <span>Read story</span>
  </div>
  <div class="hfx-image-slide-aside-photo" role="img" aria-label="Mountains at dusk"></div>
</article>

CSS

.hfx-image-slide-aside {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  width: 15em;
  height: 9.5em;
  border-radius: 0.75em;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 1px rgb(15 23 42 / 0.08);
  color: #1f2937;
  font-family: system-ui, sans-serif;
}
.hfx-image-slide-aside-text {
  display: grid;
  align-content: center;
  gap: 0.4em;
  width: 7.4em;
  height: 100%;
  padding: 0 0.9em;
  box-sizing: border-box;
}
.hfx-image-slide-aside-text > * {
  opacity: 0;
  transform: translateX(-0.8em);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.hfx-image-slide-aside strong {
  font-size: 1.05em;
}
.hfx-image-slide-aside p {
  margin: 0;
  color: #6b7280;
  font-size: 0.75em;
  line-height: 1.4;
}
.hfx-image-slide-aside span {
  color: var(--c);
  font-size: 0.75em;
  font-weight: 600;
}
.hfx-image-slide-aside-photo {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 40% at 16% 110%, color-mix(in srgb, var(--c) 18%, #0b0a1f) 99%, transparent),
    radial-gradient(66% 38% at 88% 108%, color-mix(in srgb, var(--c) 24%, #0b0a1f) 99%, transparent),
    conic-gradient(from 128deg at 68% 44%, transparent 0, color-mix(in srgb, var(--c) 32%, #1e1b4b) 0.4deg 103.6deg, transparent 104deg),
    conic-gradient(from 119deg at 90% 52%, transparent 0, color-mix(in srgb, var(--c) 32%, #1e1b4b) 0.4deg 121.6deg, transparent 122deg),
    conic-gradient(from 123deg at 24% 40%, transparent 0, color-mix(in srgb, var(--c) 42%, #6b2159) 0.4deg 113.6deg, transparent 114deg),
    conic-gradient(from 125deg at 46% 54%, transparent 0, color-mix(in srgb, var(--c) 42%, #6b2159) 0.4deg 109.6deg, transparent 110deg),
    radial-gradient(circle at 38% 58%, #fef3c7 0 1em, rgb(254 215 170 / 0.55) 1.1em, transparent 4.2em),
    linear-gradient(color-mix(in srgb, var(--c) 58%, #1e1b4b), color-mix(in srgb, var(--c) 34%, #f472b6) 52%, color-mix(in srgb, var(--c) 12%, #fdba74) 76%);
  box-shadow: -0.5em 0 1.2em rgb(15 23 42 / 0.25);
  transition: transform 0.55s cubic-bezier(0.65, 0, 0.35, 1);
}
.hfx-image-slide-aside:hover .hfx-image-slide-aside-photo {
  transform: translateX(52%);
}
.hfx-image-slide-aside:hover .hfx-image-slide-aside-text > * {
  opacity: 1;
  transform: none;
  transition: opacity 0.35s ease 0.2s, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}
.hfx-image-slide-aside:hover .hfx-image-slide-aside-text > :nth-child(2) {
  transition-delay: 0.27s;
}
.hfx-image-slide-aside:hover .hfx-image-slide-aside-text > :nth-child(3) {
  transition-delay: 0.34s;
}

@media (prefers-reduced-motion: reduce) {
  .hfx-image-slide-aside, .hfx-image-slide-aside *, .hfx-image-slide-aside::before, .hfx-image-slide-aside::after, .hfx-image-slide-aside *::before, .hfx-image-slide-aside *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • 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 hover effects