A card that lifts when you point at it feels responsive and a little bit physical, and the whole effect is carried by its shadow. At rest the shadow is short and tight. On hover it stretches downward and softens, exactly what a real object does when it rises off a surface and the light gets under it.
There is an honest catch worth stating early. The Box Shadow Generator on Ovatly produces static declarations: it has no hover states and no animation settings. What it does well is let you design each state precisely. This guide generates the resting and lifted shadows as two separate declarations, then shows the short piece of your own CSS that connects them.
Contents
- Quick answer
- What a lift actually changes
- What the generator does, and what your stylesheet does
- How to build a hover lift, step by step
- Worked example: a card that rises on hover
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Build two shadows in the Box Shadow Generator: a resting one with a small vertical offset and blur, and a lifted one with a bigger offset and a bigger blur at a similar opacity. Copy both declarations. In your own stylesheet, put the resting declaration on the element's base rule together with a transition on box-shadow, and put the lifted declaration under the element's :hover rule. The generator supplies the values; the states and the animation are yours.
What a lift actually changes
When an object rises, two things happen to its shadow. It lands further from the object, because the light now reaches further underneath. And it gets softer, because the gap lets light arrive from more angles. In CSS terms that is a larger vertical offset and a larger blur radius.
Opacity usually stays close to the resting value or drops a touch. A common failure is a hover shadow that gets darker as it grows, which reads as the object getting heavier rather than higher. Another is growing the blur without the offset, which makes the element look like it is glowing grey instead of lifting.
If your resting shadow uses two layers, a tight core and a soft halo, the lifted state should keep the same structure. The halo grows the most, since ambient spread is what height changes; the core stretches a little and lightens, because contact weakens as the object leaves the surface.
What the generator does, and what your stylesheet does
The split of labour matters, because it decides where to fix things when the effect looks wrong.
The generator designs values. You set offsets, blur, spread, color and opacity per layer, watch the preview, and copy a finished box-shadow declaration. It runs fully in your browser and knows nothing about your page, your selectors or your states.
Your stylesheet owns behaviour. Which elements get the shadow, when the lifted version applies, and how the change animates are all plain CSS that you write: a base rule, a :hover rule, and a transition property to smooth the swap. None of that comes from the tool, and this guide will not pretend otherwise. The CSS below is general stylesheet code, shown so you can see exactly where each generated declaration goes.
How to build a hover lift, step by step
- Open the Box Shadow Generator and design the resting shadow first: modest vertical offset, modest blur, restrained opacity. Copy the declaration and keep it somewhere safe.
- Without changing the color, raise the vertical offset and the blur to design the lifted state. If you use two layers, grow the halo more than the core. Copy this second declaration too.
- In your stylesheet, write the base rule for the element with the resting declaration and a transition on
box-shadow. - Add a
:hoverrule for the same element carrying the lifted declaration. Optionally add a small upwardtransformin the same rule. - Hover the element in a real page and judge the timing and distance. Adjust the generated values, not the wiring, until the lift feels calm.
Worked example: a card that rises on hover
Take a resting shadow of offsets 0px and 8px, blur 24px, spread 0px, color #000000 at 20% opacity. The generator gives you the resting declaration:
box-shadow: 0px 8px 24px 0px rgba(0, 0, 0, 0.2);
For the lifted state, push the offset down and widen the blur: offsets 0px and 16px, blur 32px, spread 0px, same black at 25% opacity at most, or keep 20% if the card sits on a light background. The second declaration:
box-shadow: 0px 16px 32px 0px rgba(0, 0, 0, 0.25);
Now the wiring, which is your CSS, not the tool's output:
.card {
box-shadow: 0px 8px 24px 0px rgba(0, 0, 0, 0.2);
transition: box-shadow 200ms ease;
}
.card:hover {
box-shadow: 0px 16px 32px 0px rgba(0, 0, 0, 0.25);
}
The browser interpolates between the two declarations over 200 milliseconds, so the shadow grows and softens smoothly in both directions. The numbers came from the generator; the .card rules are the part you own.
Limitations and honest tradeoffs
The generator cannot preview the animation. It shows each state as a still shadow, so the feel of the lift, its speed and easing, can only be judged in your page with your stylesheet. Expect one round of adjustment after the first real hover.
Transitions between shadow states only interpolate cleanly when both declarations have the same layer count in the same order. A one-layer resting shadow swapping to a two-layer hover shadow will jump rather than glide. Keep the structure identical and vary only the values.
And a lift is not free feedback for every element. Reserving it for things that are actually clickable keeps it meaningful; when every panel on the page rises, none of them feel interactive, and the motion turns into noise.
Common mistakes
- Animating with mismatched layer counts. One layer at rest, two on hover: the browser cannot pair them up and the change snaps. Match the structure.
- Making the hover shadow darker instead of longer. Darkness reads as weight. Grow the offset and blur; hold or lower the opacity.
- Forgetting the transition on the base rule. Without it, the lifted shadow appears instantly, which looks like a glitch rather than a lift.
- Lifting everything. Apply the effect to interactive elements only, or it stops signalling anything.
- Skipping the return trip. The transition runs in both directions. Check that the card settles back down as smoothly as it rose.
FAQs
Does the Box Shadow Generator create hover effects? No. It outputs static box-shadow declarations, with no hover states and no animation. You generate two declarations, one per state, and your own stylesheet applies the second one under a hover rule and animates the change.
What should change between the resting and lifted shadows? Mainly the vertical offset and the blur radius: both grow as the element rises, because a higher object casts a shadow that lands further away and spreads softer. Keep the color the same and let opacity fall slightly.
How do I make the change animate instead of snapping? Add a transition on the box-shadow property to the element's base rule in your stylesheet, with a short duration such as 200ms. The browser then interpolates between the two declarations when the hover state starts and ends.
Should the element itself move on hover too? A small upward shift of the element, using transform in your own CSS, sells the lift, because the shadow alone implies height the layout does not show. Keep it to a few pixels; the shadow does most of the work.
Can I animate a shadow built from several layers? Yes, as long as both states have the same number of layers in the same order. The browser interpolates layer by layer, so a two-layer resting shadow needs a two-layer lifted shadow to animate cleanly.
Conclusion
A hover lift is two honest shadows and one line of transition. Design both states in the Box Shadow Generator, keep their layer structure matched, and wire them together in your own stylesheet under the base and :hover rules. If you have not yet built the resting shadow itself, start with How to Use Multiple Shadows on One Element, which covers the core and halo layers in full. For more guides in this series, see our Website and Webmaster Tools guides.
References
- MDN Web Docs, on the box-shadow property and how its values are structured: https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
- MDN Web Docs, on CSS transitions and which properties animate smoothly: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions