Why Is My Box-Shadow Cut Off? Fixing the overflow: hidden Trap
October 5, 2026 | 8 min read | CSS
By Syed · Frontend Engineer & Creator of UITweak
Your card looks great on desktop. On mobile, its shadow is sliced flat on the sides, as if someone cut it with scissors. You did not change the shadow. What changed is the space around the card, and somewhere above it sits an ancestor with overflow: hidden quietly clipping everything that paints outside the card's box. That is the entire bug, and the fix is always one of the five below.
30-second diagnosis: in DevTools, select your card, then walk up its ancestors one by one checking the computed overflow value. The first ancestor with hidden, auto, scroll, or clip is your clipper. Everything below fixes a different relationship with that ancestor, so find it first.
Why This Happens
A box-shadow is painted outside the element's border box; a big soft shadow can extend dozens of pixels beyond it. Any ancestor whose overflow is anything other than visible clips everything painted outside its own box, including your shadow. One subtlety that saves debugging time: an element's own overflow: hidden does not clip its own shadow. The culprit is always above the card, never the card itself.
Fix 1: Give the Shadow Room (the Gutter)
The simplest fix: make sure there is empty space between the card and the clipping edge, at least as large as the shadow itself. Add padding to the clipping parent, or margin to the card; both create room inside the clipping box, which is what matters:
/* the shadow extends ~24px beyond the card... */
.card {
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}
/* ...so the parent needs at least that much breathing room */
.clipping-parent {
overflow: hidden;
padding: 28px; /* gutter >= blur + spread + offset */
}Size the gutter from your shadow values: it needs to cover the blur radius plus the spread plus any offset. A fast way to get those numbers exactly: build the shadow in our free Box-Shadow Studio, read off the blur, spread, and offsets, and set the gutter to at least their total. Guess the gutter and you will be back here; measure it once and you are done.
Fix 2: Re-scope the overflow: hidden
Very often the overflow: hidden is on the wrong element. The classic case: a card with rounded corners and an image at the top. The image needs clipping so its corners match the card, so someone puts overflow-hidden on the whole card, and the card's own shadow survives (remember: your own overflow does not clip your own shadow) but every child shadow inside gets cut. Move the clipping down to exactly the element that needs it:
<!-- WRONG: the whole card clips inner shadows -->
<div class="rounded-2xl overflow-hidden shadow-xl">
<img src="cover.jpg" class="w-full" />
<div class="p-6 shadow-inner ...">...</div>
</div>
<!-- RIGHT: only the image is clipped -->
<div class="rounded-2xl shadow-xl">
<div class="overflow-hidden rounded-t-2xl">
<img src="cover.jpg" class="w-full" />
</div>
<div class="p-6">...</div>
</div>Audit every overflow-hidden in your layout and ask what it is actually for. Most of them can move one level down.
Fix 3: overflow-clip-margin (the Modern Fix)
Sometimes the ancestor genuinely needs to clip (a scroll container, a masked hero). Modern browsers let you keep the clipping but grant the shadow some bleed area with overflow-clip-margin:
.clipping-parent {
/* clip instead of hidden: same visual result, but allows a margin */
overflow: clip;
overflow-clip-margin: 28px; /* shadow may paint 28px outside */
}Content still gets clipped, but the shadow is allowed to paint within the margin. Support is good in all modern browsers (Chrome 90+, Safari 16+, Firefox 81+). For anything older, the declaration is ignored and you fall back to the gutter from Fix 1, so pair them: write the padding gutter first, then add the clip margin as the cleaner override.
Fix 4: The Mobile Full-Bleed Case
If the shadow is only cut on mobile, the card is probably full-bleed: it touches the viewport edges, and the viewport itself becomes the clipper. Desktop has natural gutters from the centered container; mobile does not. The fix is a horizontal gutter on the section, not on the card:
<!-- card touches the screen edges on mobile: shadow clipped -->
<section>
<div class="card shadow-xl">...</div>
</section>
<!-- fixed: the section provides the gutter -->
<section class="px-4">
<div class="card shadow-xl">...</div>
</section>While you are here, check for horizontal page scroll on mobile too: an element wider than the viewport makes the whole page scroll sideways, and that sideways overflow clips shadows the same way. Fix the overflowing element and both problems vanish together.
Fix 5: When You Cannot Touch the Ancestor
Third-party carousels, scroll-snap containers, and library components sometimes bring their own overflow: hidden that you should not remove. In that case, move the shadow outside the clipping context instead of fighting it: wrap the clipped area in an outer div and put the shadow on the wrapper:
<!-- the carousel clips everything inside it -->
<div class="shadow-xl"> <!-- shadow lives OUTSIDE -->
<div class="carousel overflow-hidden"> <!-- clipper untouched -->
<div class="card">...</div>
</div>
</div>The wrapper paints the shadow around the whole clipped region. It changes the shadow's shape slightly (it now outlines the container, not the card), but for carousels and scrollers that is usually the look you wanted anyway.
A Note on drop-shadow()
You may see filter: drop-shadow() suggested as a fix. It is not one, at least not for clipping: a drop shadow is clipped by ancestors exactly like a box shadow. Where drop-shadow() genuinely wins is shape: it follows the element's rendered alpha, so it wraps transparent PNGs and irregular shapes while box-shadow always draws a box. Our box-shadow vs drop-shadow guide covers when to pick which; for the clipping problem in this article, use the five fixes above regardless of which shadow type you chose.
Quick Recap
- Find the clipping ancestor in DevTools (first
overflowabove the card that is notvisible). - Add a gutter (parent padding or card margin) at least as large as blur + spread + offset.
- Move
overflow: hiddendown to the element that actually needs it. - Use
overflow: clip+overflow-clip-marginwhen the ancestor must keep clipping. - On mobile, gutter the section (
px-4) so full-bleed cards are not clipped by the viewport. - If the ancestor is untouchable, put the shadow on a wrapper outside it.
Frequently Asked Questions
Does overflow: hidden on the element itself clip its own shadow?
No. Overflow clips an element's content and descendants, not the shadow the element paints itself. If your shadow is cut, the clipper is an ancestor. This single fact resolves most confused debugging sessions.
How big should the gutter be?
At least the shadow's blur radius plus its spread plus the absolute offset. For 0 12px 24px 4px, that is 24 + 4 + 12 = 40px of room. Build the shadow in the Box-Shadow Studio to read the exact numbers instead of guessing.
What is the difference between overflow: hidden and clip?
Visually they clip the same way, but clip forbids all scrolling (including programmatic) and, crucially, supports overflow-clip-margin, which lets painted effects like shadows bleed past the clip edge. hidden has no such escape hatch.
Will a bigger z-index fix it?
No. z-index controls paint order, not clipping. A shadow with z-index: 9999 inside an overflow: hidden ancestor is still clipped. Fix the clip, not the stack order.
The shadow is cut only on one side. Why?
The card is close to the clipping edge on that side only. Check for asymmetric layout: a card pushed against one edge of its parent, or an offset shadow (12px 0) reaching further in one direction. The gutter must cover the largest reach in every direction.
Try it now: rebuild your shadow in the free Box-Shadow Studio, note the blur, spread, and offset values, and set your gutter to at least their total. Then apply the fix above that matches your clipping ancestor.