What makes a good hover effect, and does it work on mobile?

A hover effect gives immediate feedback when the pointer reaches an element: scale, colour shift, underline, shine or reveal. It is built with CSS transitions on :hover and :focus-visible, pseudo-elements for underlines and shines, and small JavaScript additions for physics or a 3D tilt that follows the pointer.

How to choose, performance and accessibility
  • Pick understated effects such as Underline Expand, Color Shift or Scale & Rotate for navigation and cards, and playful ones like Like Heart, Paint Brush or Gravity Simulation for moments of delight.
  • Touch screens have no hover, so wrap hover-only styles in @media (hover: hover), never hide essential information behind a hover, and mirror every effect on keyboard focus.
  • Scale & Rotate, Background Slide, Like Heart, Paint Brush and Gravity Simulation are free with their full code; the rest come with Premium.

Scale & Rotate

Scale up with a slight rotation.

CSS Transform
Effect page →
View source code
HTML
<div class="fx-0343-root">
  <button class="hover-box hover-scale-rotate" type="button">
    <span>Scale &amp; Rotate</span>
  </button>
</div>
CSS
.fx-0343-root,
.fx-0343-root *,
.fx-0343-root *::before,
.fx-0343-root *::after {
  box-sizing: border-box
}

.fx-0343-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

/* Site design system variables this code depends on (values from css/style.css — adapt freely). */
.fx-0343-root {
  --bg-card: #12121a;
  --border: rgba(255, 255, 255, 0.08);
  --radius-xl: 1rem;
}

.fx-0343-root .hover-box {
  width: 200px;
  height: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.fx-0343-root .hover-scale-rotate {
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fx-0343-root .hover-scale-rotate:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.3);
}

.fx-0343-root .hover-scale-rotate:focus-visible {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.3);
  outline: 2px solid #6366f1;
  outline-offset: 3px;
}

.fx-0343-root .hover-box span {
  position: relative;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .fx-0343-root * {
    transition: none !important;
    animation-play-state: paused !important;
  }

  .fx-0343-root .hover-scale-rotate:hover,
  .fx-0343-root .hover-scale-rotate:focus-visible {
    transform: none;
  }
}
JavaScript
/* Pure CSS — no JavaScript required */

Background Slide

The background slides from left to right.

CSS Background
Effect page →
View source code
HTML
<div class="fx-0344-root">
  <button class="hover-box hover-bg-slide" type="button">
    <span>BG Slide</span>
  </button>
</div>
CSS
.fx-0344-root,
.fx-0344-root *,
.fx-0344-root *::before,
.fx-0344-root *::after {
  box-sizing: border-box
}

.fx-0344-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

/* Site design system variables this code depends on (values from css/style.css — adapt freely). */
.fx-0344-root {
  --bg-card: #12121a;
  --border: rgba(255, 255, 255, 0.08);
  --radius-xl: 1rem;
}

.fx-0344-root .hover-box {
  width: 200px;
  height: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.fx-0344-root .hover-bg-slide {
  background: linear-gradient(90deg, var(--bg-card) 50%, #6366f1 50%);
  background-size: 200% 100%;
  background-position: left;
  transition: all 0.5s ease;
}

.fx-0344-root .hover-bg-slide:hover {
  background-position: right;
  color: white;
}

.fx-0344-root .hover-bg-slide:focus-visible {
  background-position: right;
  color: white;
  outline: 2px solid #6366f1;
  outline-offset: 3px;
}

.fx-0344-root .hover-box span {
  position: relative;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .fx-0344-root * {
    transition: none !important;
    animation-play-state: paused !important;
  }
}
JavaScript
/* Pure CSS — no JavaScript required */

Border Gradient

Gradient border that appears on hover.

CSS Border

Shine Effect

Light reflection that sweeps across the element.

CSS Light

Underline Expand

Line that expands from the center.

CSS Line

Icon Bounce

The icon bounces on hover.

CSS Animation

Color Shift

Smooth color transition.

CSS Color

Blur Reveal

The blurred element becomes sharp on hover.

CSS Filter

Shadow Inset

Glowing inner shadow.

CSS Shadow

Tilt 3D

Perspective tilt on hover.

CSS 3D

Shutter Reveal

Shutter effect that opens on hover.

CSS Reveal

Glitch Hover

RGB glitch effect on hover.

CSS Glitch

Fill Up

Bottom-to-top fill with an ease-quart curve.

CSS Fill Bezier

Filter Animated

On hover, the element's hues cycle continuously (CSS filters).

CSS Filter GPU

Spotlight Effect

Spotlight effect that follows the cursor on the element.

JS Mouse Light

Magnetic Pull

The element is attracted to the cursor with a magnetic effect.

JS Mouse Physics

Elastic Scale

Scale up with elastic curve and natural bounce.

CSS Bezier Scale

Gradient Shift

Animated gradient that speeds up on hover for a dynamic effect.

CSS Gradient Animation
423 likes

Like Heart

Like button with pop animation, propagation ring and colorful particle burst on click.

CSS Animation Interactive
Effect page →
View source code
HTML
<div class="fx-0361-root">
  <div class="mi-heart-scene">
    <button class="mi-heart-btn" aria-pressed="false" aria-label="Like">
      <svg viewBox="0 0 24 24"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>
      <div class="mi-heart-particles">
        <span class="mi-heart-particle"></span>
        <span class="mi-heart-particle"></span>
        <span class="mi-heart-particle"></span>
        <span class="mi-heart-particle"></span>
        <span class="mi-heart-particle"></span>
        <span class="mi-heart-particle"></span>
        <span class="mi-heart-particle"></span>
        <span class="mi-heart-particle"></span>
      </div>
    </button>
    <span class="mi-heart-count">423 likes</span>
  </div>
</div>
CSS
.fx-0361-root,
.fx-0361-root *,
.fx-0361-root *::before,
.fx-0361-root *::after {
  box-sizing: border-box
}

.fx-0361-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.mi-heart-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.mi-heart-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.mi-heart-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.mi-heart-btn:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 3px;
}

.mi-heart-btn svg {
  width: 36px;
  height: 36px;
  stroke: rgba(255, 255, 255, 0.5);
  fill: none;
  stroke-width: 2;
  transition: stroke 0.3s ease, fill 0.3s ease;
}

.mi-heart-btn.liked svg {
  stroke: #ef4444;
  fill: #ef4444;
  animation: miHeartPop 0.4s cubic-bezier(0.17, 0.89, 0.32, 1.49);
}

.mi-heart-btn.liked::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #ef4444;
  animation: miHeartRing 0.6s ease-out forwards;
}

.mi-heart-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mi-heart-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  opacity: 0;
}

.mi-heart-btn.liked .mi-heart-particle {
  animation: miParticleBurst 0.6s ease-out forwards;
}

.mi-heart-particle:nth-child(1) { background: #ef4444; --angle: 0deg; }
.mi-heart-particle:nth-child(2) { background: #f97316; --angle: 45deg; }
.mi-heart-particle:nth-child(3) { background: #eab308; --angle: 90deg; }
.mi-heart-particle:nth-child(4) { background: #ef4444; --angle: 135deg; }
.mi-heart-particle:nth-child(5) { background: #ec4899; --angle: 180deg; }
.mi-heart-particle:nth-child(6) { background: #f97316; --angle: 225deg; }
.mi-heart-particle:nth-child(7) { background: #eab308; --angle: 270deg; }
.mi-heart-particle:nth-child(8) { background: #ec4899; --angle: 315deg; }

.mi-heart-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.3s ease;
}

.mi-heart-btn.liked ~ .mi-heart-count {
  color: #ef4444;
}

@keyframes miHeartPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes miHeartRing {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

@keyframes miParticleBurst {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-40px); }
}

@media (prefers-reduced-motion: reduce) {
  .mi-heart-btn { transition: background-color 0.15s, border-color 0.15s; }
  .mi-heart-btn svg { transition: stroke 0.15s, fill 0.15s; }
  .mi-heart-btn.liked svg { animation: none; }
  .mi-heart-btn.liked::after { animation: none; opacity: 0; }
  .mi-heart-btn.liked .mi-heart-particle { animation: none; }
}
JavaScript
!function(){document.querySelectorAll('.fx-0361-root').forEach(function(root){var btn=root.querySelector('.mi-heart-btn');if(!btn)return;btn.addEventListener('click',function(){var liked=btn.classList.toggle('liked');btn.setAttribute('aria-pressed',liked?'true':'false');});})}();

Bookmark Toggle

Save button with drop animation, background fill and color transition.

CSS Toggle Animation

Submit Button

Submit button with circular morphing, loading spinner and success check animation.

CSS JS States

Ripple Click

Material Design ripple effect on click. The wave spreads from the contact point and fades out.

CSS JS Material

Pull to Refresh

Pull to refresh: drag the list down (finger or mouse), the indicator spins and the content reloads.

CSS JS Mobile

Notification Bell

Bell with shake animation, counter badge with pop-in and sliding notification toast.

CSS JS Notification

Star Rating

Rating system with pop and rotation animation on each star. Dynamic labels based on the rating.

CSS JS Rating

Switch with Icons

Switches with icons embedded in the knob, bounce animation and color change.

CSS Toggle Icons

Copy to Clipboard

Copy button with icon transition (copy → check), success color and "Copied" tooltip.

CSS JS Clipboard

Confetti Button

Button that triggers a colorful confetti burst with realistic gravity and rotation.

JS Canvas Animation

Paint Brush

Glowing brush that leaves a colorful trail.

Canvas Draw Creative
Effect page →
View source code
HTML
<div class="fx-0371-root">
  <canvas class="pb-canvas" aria-label="Drawing area"></canvas>
  <span class="pb-label" aria-hidden="true">Draw with your mouse or finger</span>
</div>
CSS
.fx-0371-root,.fx-0371-root *,.fx-0371-root *::before,.fx-0371-root *::after{box-sizing:border-box}
.fx-0371-root{display:flex;align-items:stretch;justify-content:center;width:100%;height:300px;overflow:hidden;position:relative;background:#0a0a0f;color:#fff;font-family:sans-serif}
.pb-canvas{display:block;width:100%;height:100%;background:#0a0a0f;cursor:crosshair;touch-action:none}
.pb-label{position:absolute;bottom:10px;left:50%;transform:translateX(-50%);font-size:.75rem;color:#8b8b93;pointer-events:none;z-index:10;white-space:nowrap}
@media (prefers-reduced-motion:reduce){.fx-0371-root .pb-canvas{cursor:default}}
JavaScript
(function(){
  var reduceMotion=window.matchMedia('(prefers-reduced-motion:reduce)').matches;
  document.querySelectorAll('.fx-0371-root').forEach(function(root){
    var canvas=root.querySelector('.pb-canvas');
    if(!canvas)return;
    var ctx=canvas.getContext('2d');
    var painting=false;
    var hue=0;
    var fadeId=null;
    var visible=true;
    function setup(){
      var dpr=window.devicePixelRatio||1;
      var w=canvas.clientWidth;
      var h=canvas.clientHeight;
      canvas.width=Math.round(w*dpr);
      canvas.height=Math.round(h*dpr);
      ctx.setTransform(dpr,0,0,dpr,0,0);
      ctx.fillStyle='#0a0a0f';
      ctx.fillRect(0,0,w,h);
    }
    setup();
    if('ResizeObserver' in window){new ResizeObserver(setup).observe(canvas);}
    function getPos(e){
      var rect=canvas.getBoundingClientRect();
      var src=e.touches?e.touches[0]:e;
      return{x:src.clientX-rect.left,y:src.clientY-rect.top};
    }
    function draw(e){
      if(!painting)return;
      var p=getPos(e);
      ctx.beginPath();
      ctx.arc(p.x,p.y,15,0,Math.PI*2);
      ctx.fillStyle='hsl('+hue+',70%,60%)';
      ctx.fill();
      hue=(hue+2)%360;
    }
    canvas.addEventListener('mousedown',function(){painting=true;});
    canvas.addEventListener('mouseup',function(){painting=false;});
    canvas.addEventListener('mouseleave',function(){painting=false;});
    canvas.addEventListener('mousemove',draw);
    canvas.addEventListener('touchstart',function(e){e.preventDefault();painting=true;},{passive:false});
    canvas.addEventListener('touchend',function(){painting=false;});
    canvas.addEventListener('touchmove',function(e){e.preventDefault();draw(e);},{passive:false});
    if(!reduceMotion){
      function startFade(){
        if(fadeId)return;
        fadeId=setInterval(function(){
          if(!visible){clearInterval(fadeId);fadeId=null;return;}
          ctx.fillStyle='rgba(10,10,15,.02)';
          var dpr=window.devicePixelRatio||1;
          ctx.fillRect(0,0,canvas.width/dpr,canvas.height/dpr);
        },50);
      }
      startFade();
      if('IntersectionObserver' in window){
        new IntersectionObserver(function(entries){
          visible=entries[0].isIntersecting;
          if(visible&&!fadeId)startFade();
          if(!visible&&fadeId){clearInterval(fadeId);fadeId=null;}
        }).observe(canvas);
      }
    }
  });
})();

Repel Particles

Particles that flee from the cursor.

JS Particles Physics

Text Scramble

Text that decodes on hover.

JS Text Decode

Elastic Drag

Draggable element with elastic return.

JS Drag Spring

Scratch Reveal

Scratch to reveal the hidden content.

Canvas Reveal Game

Morph on Click

Shape that transforms on each click.

CSS JS Transform

Live Typing

Click, then type: each character appears with an animation.

JS Keyboard Animation

Sound Visualizer

Real-time sound visualizer: 20 frequency bars, driven by a built-in demo, your audio player or the microphone.

JS Audio Visual

Magnetic Letters

Letters drawn to the cursor; a click switches to repulsion. They spring back into place.

JS Physics Text

Gravity Drag

Elements that fall with gravity once released.

JS Physics Drag
Click to add balls

Gravity Simulation

Balls subjected to gravity with bounce.

JS Physics Interactive
Effect page →
View source code
HTML
<div class="fx-0381-root">
  <div class="gs381-container">
    <span class="gs381-label">Click to add balls</span>
  </div>
</div>
CSS
.fx-0381-root,.fx-0381-root *,.fx-0381-root *::before,.fx-0381-root *::after{box-sizing:border-box}.fx-0381-root{--text-muted:#8b8b93;display:flex;align-items:center;justify-content:center;width:100%;height:250px;overflow:hidden;position:relative;background:rgb(26,26,36);color:rgb(255,255,255);font-family:sans-serif}.gs381-container{width:100%;height:250px;position:relative;overflow:hidden}.gs381-ball{position:absolute;width:30px;height:30px;border-radius:50%;cursor:pointer}.gs381-label{position:absolute;bottom:10px;left:50%;transform:translateX(-50%);font-size:.75rem;color:var(--text-muted);pointer-events:none;z-index:10;white-space:nowrap}
JavaScript
(function(){var pref=window.matchMedia('(prefers-reduced-motion: reduce)');document.querySelectorAll('.fx-0381-root').forEach(function(root){var container=root.querySelector('.gs381-container');if(!container)return;var balls=[];var gravity=.5,bounce=.7,friction=.99;var rafId=null,lastTs=0;container.addEventListener('click',function(e){var r=container.getBoundingClientRect();var ball=document.createElement('div');ball.className='gs381-ball';ball.style.background='hsl('+(Math.random()*360)+',70%,60%)';var x=e.clientX-r.left-15,y=e.clientY-r.top-15;ball.style.left=x+'px';ball.style.top=y+'px';container.appendChild(ball);balls.push({el:ball,x:x,y:y,vx:(Math.random()-.5)*10,vy:0});if(balls.length>20){var old=balls.shift();old.el.remove()}});container.addEventListener('touchstart',function(e){e.preventDefault();var r=container.getBoundingClientRect();var ball=document.createElement('div');ball.className='gs381-ball';ball.style.background='hsl('+(Math.random()*360)+',70%,60%)';var x=e.touches[0].clientX-r.left-15,y=e.touches[0].clientY-r.top-15;ball.style.left=x+'px';ball.style.top=y+'px';container.appendChild(ball);balls.push({el:ball,x:x,y:y,vx:(Math.random()-.5)*10,vy:0});if(balls.length>20){var old=balls.shift();old.el.remove()}},{passive:false});if(pref.matches)return;function loop(ts){var dt=lastTs>0?Math.min(ts-lastTs,50):16.67;var f=dt/16.67;lastTs=ts;var h=container.offsetHeight,w=container.offsetWidth;balls.forEach(function(b){b.vy+=gravity*f;b.vx*=Math.pow(friction,f);b.x+=b.vx*f;b.y+=b.vy*f;if(b.y>h-30){b.y=h-30;b.vy*=-bounce}if(b.x<0){b.x=0;b.vx*=-bounce}if(b.x>w-30){b.x=w-30;b.vx*=-bounce}b.el.style.left=b.x+'px';b.el.style.top=b.y+'px'});rafId=requestAnimationFrame(loop)}function start(){if(!rafId)rafId=requestAnimationFrame(loop)}function stop(){if(rafId){cancelAnimationFrame(rafId);rafId=null;lastTs=0}}new IntersectionObserver(function(en){en[0].isIntersecting?start():stop()}).observe(root);start()})})();

Elastic String

Elastic string that reacts to the cursor.

JS Elastic Mouse

Magnetic Field

Particles attracted by a magnetic field.

JS Magnetic Particles

Newton's Cradle Loop

Five pendulums that swing on their own and restart in a loop.

JS Pendulum Energy

Liquid Simulation

The cursor pushes the drops away: the pool opens around it and its edges merge.

JS Fluid Metaball

Spring Physics

Elastic animation with spring effect.

JS Spring Bounce

Collision Detection

Balls that bounce off each other.

JS Collision Physics

Cloth Simulation

Interactive cloth simulation.

Canvas Cloth Interactive

Interactive Newton's Cradle

Grab a ball and let go: the impact travels through the row (mouse or finger).

Canvas Physics Momentum

Rope Physics

Interactive rope with physics simulation.

Canvas Verlet Draggable

Fluid X-Ray Reveal

The cursor "scans" and reveals a hidden layer — here, the same person in costume. Fluid trailing mask. Before/after, normal/disguised, day/night: the 2nd layer can be anything.

💡 Perfect for: before/after, "see the costume", Halloween party teaser, visual comparison, portrait easter egg.

CSS Mask Vanilla JS Hover Premium

Scratch Coupon Reveal

A scratch card that reveals a promo code, then lets users copy it. Tactile, gamified interaction that showcases your offer. Code and reveal threshold are both customizable.

💡 Perfect for: promo codes, contests, loyalty programs, Black Friday, offer pop-ups, e-commerce gamification.

Canvas Scratch Coupon Premium

Gift Unwrap Reveal

A gift that spins on itself, lid lifting to reveal a promo code (or any content) with a bouncy spring animation and a burst of sparks. A memorable way to unveil a festive offer. Code is fully customizable.

💡 Perfect for: Christmas promo codes, offer reveals, contests, holiday greetings, surprise calendars, festive e-commerce.

Vanilla JS Reveal Festive Free
View source code
HTML
<div class="fx-0812-root">
  <div class="guw-scene" data-guw data-code="NOEL30">
    <button type="button" class="guw-gift" data-guw-box aria-label="Open the gift">
      <span class="guw-inner" aria-hidden="true">
        <span class="guw-code" data-guw-code>🎄 NOEL30</span>
        <span class="guw-box"></span>
        <span class="guw-lid"></span>
        <span class="guw-bow">🎀</span>
      </span>
    </button>
    <div class="guw-hint" aria-hidden="true">Click to unwrap</div>
  </div>
</div>
CSS
.fx-0812-root,
.fx-0812-root *,
.fx-0812-root *::before,
.fx-0812-root *::after {
  box-sizing: border-box
}

.fx-0812-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.guw-scene {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 330px;
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #241433, #0b0a14 72%);
}

.guw-gift {
  position: relative;
  width: 220px;
  height: 250px;
  border: 0;
  background: none;
  cursor: pointer;
  outline-offset: 8px;
}

.guw-gift:focus-visible {
  outline: 2px solid #fb7185;
  border-radius: 12px;
}

.guw-code {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%) translateY(0) scale(.6);
  z-index: 3;
  background: linear-gradient(135deg, #ffe08a, #f2a900);
  color: #5b3a00;
  font-weight: 800;
  letter-spacing: .06em;
  font-size: 16px;
  padding: 9px 16px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .4);
  border: 2px dashed #b97e00;
  transition: transform .55s cubic-bezier(.2, 1.55, .35, 1);
  transition-delay: 0s;
}

.guw-box {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  width: 140px;
  height: 96px;
  border-radius: 9px;
  z-index: 4;
  background: linear-gradient(135deg, #e01e37, #9c0f20);
  box-shadow: inset 0 -10px 16px rgba(0, 0, 0, .32), 0 14px 22px rgba(0, 0, 0, .4);
}

.guw-box::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 24px;
  height: 100%;
  background: linear-gradient(#ffd166, #f2a900);
}

.guw-box::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: 24px;
  background: linear-gradient(90deg, #f2a900, #ffd166);
}

.guw-lid {
  position: absolute;
  left: 50%;
  bottom: 124px;
  transform: translateX(-50%) translateY(0) rotate(0);
  width: 162px;
  height: 40px;
  border-radius: 9px;
  z-index: 6;
  background: linear-gradient(135deg, #f0263f, #b01225);
  box-shadow: 0 6px 12px rgba(0, 0, 0, .35);
  transition: transform .5s cubic-bezier(.34, 1.3, .5, 1);
  transition-delay: .55s;
}

.guw-lid::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 24px;
  height: 100%;
  background: linear-gradient(#ffd166, #f2a900);
}

.guw-bow {
  position: absolute;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%) translateY(0);
  font-size: 40px;
  z-index: 7;
  transition: transform .5s cubic-bezier(.34, 1.3, .5, 1);
  transition-delay: .55s;
}

.guw-inner {
  position: absolute;
  inset: 0;
  transform-origin: 50% 70%;
  transition: transform .75s cubic-bezier(.45, .05, .2, 1);
  transition-delay: .9s;
}

.guw-gift.guw-open .guw-inner {
  transform: rotate(360deg);
  transition-delay: 0s;
}

.guw-gift.guw-open .guw-lid {
  transform: translateX(-50%) translateY(-86px) rotate(-10deg);
  transition-delay: .78s;
}

.guw-gift.guw-open .guw-bow {
  transform: translateX(-50%) translateY(-104px) rotate(28deg);
  transition-delay: .78s;
}

.guw-gift.guw-open .guw-code {
  transform: translateX(-50%) translateY(-104px) scale(1);
  transition-delay: 1s;
}

.guw-spark {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffd166;
  z-index: 8;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: guw-spark .75s ease-out forwards;
}

.guw-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #fb7185;
  opacity: .6;
  pointer-events: none;
  transition: opacity .3s;
}

.guw-scene.guw-done .guw-hint {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {

  .guw-inner,
  .guw-lid,
  .guw-bow,
  .guw-code {
    transition: none !important;
  }
}

@keyframes guw-spark {
  to {
    transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(.2);
    opacity: 0;
  }
}
JavaScript
(function() {
  /* Sprint décembre 2026 — Noël — Gift Unwrap Reveal (fx-0812) */
  (function() {
    var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

    document.querySelectorAll('[data-guw]').forEach(function(scene) {
      var gift = scene.querySelector('[data-guw-box]');
      var code = scene.querySelector('[data-guw-code]');
      if (scene.dataset.code) code.textContent = '🎄 ' + scene.dataset.code;
      var open = false;

      function burst() {
        if (reduceMotion) return;
        for (var i = 0; i < 12; i++) {
          var s = document.createElement('span');
          s.className = 'guw-spark';
          s.style.left = '50%';
          s.style.bottom = '150px';
          var a = (i / 12) * 6.2832 + Math.random() * 0.4,
            d = 50 + Math.random() * 50;
          s.style.setProperty('--dx', Math.cos(a) * d + 'px');
          s.style.setProperty('--dy', -Math.abs(Math.sin(a) * d) - 10 + 'px');
          gift.appendChild(s);
          (function(el) {
            setTimeout(function() {
              el.remove();
            }, 800);
          })(s);
        }
      }

      function toggle() {
        open = !open;
        gift.classList.toggle('guw-open', open);
        scene.classList.toggle('guw-done', open);
        gift.setAttribute('aria-label', open ? 'Cadeau ouvert (cliquer pour ré-emballer)' : 'Ouvrir le cadeau');
        if (open) setTimeout(burst, reduceMotion ? 0 : 1100);
      }
      gift.addEventListener('click', toggle);
      gift.addEventListener('keydown', function(e) {
        if (e.key === 'Enter' || e.key === ' ') {
          e.preventDefault();
          toggle();
        }
      });
    });
  })();
})();

Frequently Asked Questions

What is the best hover effect for a card? +

The lift effect (translateY(-8px) + box-shadow) is the most popular and effective. It creates a sense of depth without being distracting. Add a border-color transition to enhance the visual feedback.

How to create an animated underline on hover? +

Use a ::after pseudo-element with position:absolute, bottom:0, height:2px, and width:0. On hover, animate width to 100%. For a center-out effect: left:50%, transform:translateX(-50%), animate width.

How to create a 3D tilt effect on hover? +

Listen for mousemove on the card. Calculate the cursor position relative to the center. Apply transform: perspective(1000px) rotateX(Xdeg) rotateY(Ydeg) with the calculated angles. Add a transition for smoothness.

Do hover effects work on mobile? +

No — there is no hover on touch devices. Use @media (hover: hover) to target only devices with a pointer. On mobile, replace with click/tap effects using :active or JavaScript.

How to animate an image on hover? +

The most popular effects: zoom (transform: scale(1.1) inside overflow:hidden), appearing overlay (pseudo-element with opacity), filter (grayscale to color), and clip-path revealing hidden content.