AI CSS Animations

Content Rise Card

The title sits low on the image; on hover it rises and a description fades in beneath it. Everything is positioned inside the image, so the card's footprint never changes.

Also known as: hover reveal description, text slide up card.

Sintra day trip

Palaces, mist and pastel walls, forty minutes from the city.

HTML

<figure class="hfx-card-content-rise">
  <div class="hfx-card-content-rise-image"></div>
  <figcaption>
    <h3>Sintra day trip</h3>
    <p>Palaces, mist and pastel walls, forty minutes from the city.</p>
  </figcaption>
</figure>

CSS

.hfx-card-content-rise {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  width: 15em;
  border-radius: 0.75em;
  overflow: hidden;
  background: #fff;
  border: 1px solid color-mix(in srgb, #000 10%, transparent);
  color: #1f2937;
  font-family: system-ui, sans-serif;
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 3;}
.hfx-card-content-rise-image {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 45%, #fff), var(--c));
}
.hfx-card-content-rise figcaption {
  position: absolute;
  inset: auto 0 0;
  padding: 1em;
  background: linear-gradient(to top, color-mix(in srgb, #000 70%, transparent), transparent);
  color: #fff;
  transform: translateY(1.8em);
  transition: transform 0.35s ease;
}
.hfx-card-content-rise h3 { margin: 0; font-size: 1.05em; }
.hfx-card-content-rise p {
  margin: 0.3em 0 0;
  font-size: 0.8em;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.35s ease 0.1s;
}
.hfx-card-content-rise:hover figcaption { transform: translateY(0); }
.hfx-card-content-rise:hover p { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .hfx-card-content-rise, .hfx-card-content-rise *, .hfx-card-content-rise::before, .hfx-card-content-rise::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