Pair an offset radial gradient with inset and outer shadows
Admin ·
When a card needs both a color highlight and depth, keep the source of each effect identifiable. Put the highlight in the gradient, then add an outer shadow and a separate inset edge so you can tune them independently.
CSS Box Shadow Gradient Playground
Position the highlight near the upper left
Choose Radial. Set the center to X 30% and Y 40%, the start color to #FFDF91 at 25%, and the end color to #334E68 at 75%. Set the corner radius to 20 px.
The light region should shift toward the upper left. Move X to 70% to confirm that the highlight shifts right while the shadow stays fixed, then return X to 30%.
Separate the outer depth from the inset edge
Keep the original shadow with Y offset 16 px, blur 36 px and spread -10 px. Add a second shadow. Enable Inset shadow and change its color to #FFFFFF and opacity to 60%. Preview the soft light edge inside the card.
If you stack two shadows in the same region, their order matters. The first shadow is painted on top of later ones. Move a layer to compare the overlap. If an outer layer extends too far, try a more negative spread before reducing the blur.
Apply and inspect the downloaded rule
Download gradient-card.css and add the gradient-card class to an element with its own layout dimensions or content. Check for circle at 30% 40%, the 25% and 75% stops, two comma-separated box shadows and a 20 px border radius.
Try equal color stop positions for a hard edge or choose Conic if you want colors distributed around the center. If part of a shadow is missing in your page, check whether a parent container clips overflow.
W3C CSS Images Level 3, gradient types and stopsCSS Working Group CSS Images Level 4 draft, conic gradientsW3C CSS Backgrounds and Borders, box-shadow painting order
Common questions
Can I use a translucent gradient color?
Yes. Enter an alpha value such as #FFDF9180 or rgb(255 223 145 / 50%). The color blends with whatever sits behind the card.
What happens if I remove every shadow layer?
The generated rule uses box-shadow: none and keeps the gradient and corner radius.
Sources
Put it into practice.
Related guides
- How to Make a CSS Gradient: Linear and Radial
- Compare Glass Blur and Clay Shadows
- See What Changes When You Reorder CSS Filters
- Compare Rounded Corners at Two Box Sizes
- Build a Two-Layer CSS Text Glow
- Position Three Lights in a Mesh Gradient
- Build a Responsive Card and Verify Its Layout
- Build a Gradient with a Measured Repeat
- Test Linked and Per-Side CSS Borders
- Build a Soft CSS Card with Two Shadows