iPhone
iOS
box-shadow
display issue
CSS

iPhone iOS will not display box-shadow properly

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

When box-shadow looks fine on desktop browsers but disappears, clips, or renders strangely on iPhone Safari, the root cause is usually not the shadow declaration itself. The problem is often a surrounding layout rule such as overflow: hidden, a transformed ancestor, or an element being promoted to a composited layer in a way that changes clipping.

The fastest way to debug this on iOS is to stop thinking "Safari does not support box-shadow" and instead ask "which parent or rendering condition is preventing the shadow from being painted visibly."

Start with a Minimal Shadow

A normal shadow declaration is straightforward:

css
1.card {
2  background: white;
3  border-radius: 16px;
4  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
5}

If this fails only on iPhone, isolate the element in a minimal page before changing the shadow values. In many cases, the shadow is valid but is being clipped by the element or its parent.

The Most Common Cause: Clipping by overflow

The most frequent reason for a missing shadow on iOS is an ancestor with overflow: hidden, overflow: auto, or a scroll container that clips the painted area outside the element's box.

Example:

css
1.list {
2  overflow: hidden;
3  padding: 12px;
4}
5
6.card {
7  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
8}

On some layouts, the shadow exists but gets cut off at the container edge. The simplest fix is to allow visible overflow or move the shadow-bearing element outside the clipped container.

css
.list {
  overflow: visible;
}

If you cannot change the container overflow because it controls scrolling or masking, wrap the card:

html
<div class="card-shell">
  <div class="card">Content</div>
</div>
css
1.card-shell {
2  padding: 16px;
3}
4
5.card {
6  border-radius: 16px;
7  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
8}

The wrapper creates room for the shadow without forcing the content container to overflow.

Border Radius, Transforms, and Composited Layers

iPhone Safari can also behave differently when shadows are combined with:

  • 'border-radius'
  • 'transform'
  • 'position: fixed'
  • scroll containers with momentum scrolling

For example, an element with both overflow: hidden and border-radius often clips its own shadow:

css
1.card {
2  overflow: hidden;
3  border-radius: 16px;
4  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
5}

That is not really an iOS-only bug. The box is clipping the paint area by design. The usual fix is to split clipping and shadow into two layers:

html
<div class="card-shadow">
  <div class="card-content">Content</div>
</div>
css
1.card-shadow {
2  border-radius: 16px;
3  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
4}
5
6.card-content {
7  overflow: hidden;
8  border-radius: 16px;
9  background: white;
10}

Now the outer layer paints the shadow and the inner layer clips the content.

When filter: drop-shadow(...) Helps

Sometimes Safari renders a complex visual better with filter: drop-shadow(...) than with box-shadow, especially when the element shape or transparency is unusual.

css
.badge {
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

This is not a universal replacement. drop-shadow follows the rendered alpha shape, while box-shadow follows the element box. But it can be a practical workaround for specific iOS rendering issues.

Practical Debugging Approach

Use a reduction strategy:

  1. Remove all parent overflow rules.
  2. Remove transform from the element and ancestors.
  3. Remove position: fixed or sticky behavior temporarily.
  4. Test the shadow with a plain rectangular element.
  5. Reintroduce styles one at a time.

That process usually identifies the actual conflict faster than changing blur and spread values at random.

If the problem is hard to reproduce, inspect the page with Safari's remote Web Inspector while the site is open on the iPhone. Seeing the computed styles and toggling overflow or transform live is usually faster than guessing from screenshots.

Common Pitfalls

The biggest pitfall is putting overflow: hidden and box-shadow on the same element and expecting both rounded clipping and a visible outer shadow. Those goals usually require two nested elements.

Another issue is debugging only the shadow declaration. On iPhone, the shadow may be correct while the true bug lives in a parent scroll container or stacking context.

Developers also sometimes use huge blur radii on animated elements, which can trigger performance problems and make the rendering appear inconsistent during scrolling.

Finally, do not assume -webkit- prefixes are the answer. Modern Safari supports box-shadow normally. The bug is usually structural, not a missing vendor prefix.

Summary

  • iPhone Safari usually supports box-shadow; missing shadows are often caused by clipping or layout interactions.
  • Check parent overflow, element border-radius, transforms, and fixed-position ancestors.
  • Use a wrapper when you need both clipped content and a visible outer shadow.
  • 'filter: drop-shadow(...) can help in some edge cases, but it is not identical to box-shadow.'
  • Debug by stripping the layout down to a minimal reproducible case and restoring styles gradually.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.