
Each preset combines multiple layered shadows with carefully calibrated opacity values to simulate how light interacts with surfaces at different elevations.
How to use it:
1. Open the Shadow.css demo page and select the shadow style that matches your elevation needs. Copy the CSS definition and paste it into your stylesheet.
shadow-4: Four-layer shadow with consistent 0.15 opacity across all layers. This creates balanced elevation suitable for standard cards and panels.
.shadow-4 {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15), 0 2px 2px rgba(0, 0, 0, 0.15),
0 4px 4px rgba(0, 0, 0, 0.15), 0 8px 8px rgba(0, 0, 0, 0.15);
}
shadow-5: Five-layer shadow with uniform 0.12 opacity. The lighter opacity produces softer edges compared to shadow-4.
.shadow-5 {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 0 2px 2px rgba(0, 0, 0, 0.12),
0 4px 4px rgba(0, 0, 0, 0.12), 0 8px 8px rgba(0, 0, 0, 0.12),
0 16px 16px rgba(0, 0, 0, 0.12);
}
shadow-6: Six-layer shadow with 0.11 opacity extending to 32px blur radius. This creates the most gradual depth transition in the numbered presets.
.shadow-6 {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.11), 0 2px 2px rgba(0, 0, 0, 0.11),
0 4px 4px rgba(0, 0, 0, 0.11), 0 8px 8px rgba(0, 0, 0, 0.11),
0 16px 16px rgba(0, 0, 0, 0.11), 0 32px 32px rgba(0, 0, 0, 0.11);
}
shadow-sharp: Five-layer shadow with decreasing opacity from 0.25 to 0.05. The strong initial opacity creates crisp edges that soften gradually.
.shadow-sharp {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25), 0 2px 2px rgba(0, 0, 0, 0.2),
0 4px 4px rgba(0, 0, 0, 0.15), 0 8px 8px rgba(0, 0, 0, 0.1),
0 16px 16px rgba(0, 0, 0, 0.05);
}
shadow-diffuse: Four-layer shadow with increasing opacity from 0.08 to 0.2. This inverted pattern produces softer inner edges and stronger outer glow.
.shadow-diffuse {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08), 0 2px 2px rgba(0, 0, 0, 0.12),
0 4px 4px rgba(0, 0, 0, 0.16), 0 8px 8px rgba(0, 0, 0, 0.2);
}
shadow-dreamy: Six-layer shadow with consistent 0.07 opacity extending to 64px blur radius. The extreme blur radius creates soft, atmospheric depth.
.shadow-dreamy {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.07),
0 4px 8px rgba(0, 0, 0, 0.07), 0 8px 16px rgba(0, 0, 0, 0.07),
0 16px 32px rgba(0, 0, 0, 0.07), 0 32px 64px rgba(0, 0, 0, 0.07);
}
shadow-shorter: Five-layer shadow with 0.11 opacity stopping at 16px blur radius. The compressed layer distribution creates tighter depth perception.
.shadow-shorter {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.11), 0 2px 2px rgba(0, 0, 0, 0.11),
0 4px 4px rgba(0, 0, 0, 0.11), 0 6px 8px rgba(0, 0, 0, 0.11),
0 8px 16px rgba(0, 0, 0, 0.11);
}
shadow-longer: Five-layer shadow with 0.09 opacity extending to 32px blur radius. The doubled y-offset values push shadows farther below elements.
.shadow-longer {
box-shadow: 0 2px 1px rgba(0, 0, 0, 0.09), 0 4px 2px rgba(0, 0, 0, 0.09),
0 8px 4px rgba(0, 0, 0, 0.09), 0 16px 8px rgba(0, 0, 0, 0.09),
0 32px 16px rgba(0, 0, 0, 0.09);
}
2. Or download the shadow.css file and link it in your HTML document’s head section:
<link rel="stylesheet" href="./shadow.css" />
Then apply shadow classes directly to your HTML elements:
<div class="shadow-4"></div> <div class="shadow-5"></div> <div class="shadow-6"></div> <div class="shadow-sharp"></div> <div class="shadow-diffuse"></div> <div class="shadow-dreamy"></div> <div class="shadow-shorter"></div> <div class="shadow-longer"></div>
Changelog:
11/29/2025
- Update Demo & Doc
The post 8 Elegant CSS Box Shadow Presets (Copy & Paste) – Shadow.css appeared first on CSS Script.
Discover more from RSS Feeds Cloud
Subscribe to get the latest posts sent to your email.
