CSS Box-Shadow & Gradient Generator

Box-Shadow

Linear Gradient

Generated CSS



    

CSS Box-Shadow & Linear-Gradient Guide

Subtle shadows and smooth gradients give web interfaces depth, hierarchy, and polish without heavy background images. This visual generator lets you experiment with box-shadow parameters and two-stop linear-gradient() backgrounds in real time and copy production-ready CSS in one click.

Understanding box-shadow Values

The CSS box-shadow property accepts up to five values plus an optional inset keyword:

  • Horizontal Offset (offset-x): Positive values push the shadow to the right; negative values push it to the left.
  • Vertical Offset (offset-y): Positive values drop the shadow downward (simulating overhead light); negative values lift it upward.
  • Blur Radius (blur-radius): Controls how soft the shadow edge is. 0px produces a sharp hard-edged shadow; 20px–40px creates a soft ambient elevation.
  • Spread Radius (spread-radius): Expands (positive) or shrinks (negative) the shadow size before blurring. A negative spread (e.g. -4px) paired with a larger blur creates clean, modern card shadows that do not bleed excessively on the sides.
  • Color & Opacity: Using rgba(0, 0, 0, 0.12) instead of solid hex keeps shadows natural over colored surfaces.

Understanding linear-gradient()

A CSS linear-gradient(angle, color1, color2) draws a smooth transition along a straight line defined by an angle in degrees: 0deg points straight up, 90deg points left-to-right, 135deg runs diagonally from top-left to bottom-right, and 180deg runs top-to-bottom. Because gradients are generated by the browser's rendering engine, they scale crisply on Retina/4K displays with zero HTTP requests.

Practical Tips & FAQ

  • How do I create layered "Material" shadows? Combine two comma-separated shadows in CSS: one tight shadow (0 1px 3px rgba(0,0,0,0.12)) for crisp contact and one soft shadow (0 10px 25px rgba(0,0,0,0.08)) for elevation.
  • Does box-shadow affect layout? No. Shadows are painted outside the box model and do not shift neighboring elements or trigger layout reflows.
  • Should I still use -webkit- prefixes? Modern browsers (Chrome, Firefox, Safari, Edge) have supported unprefixed box-shadow and linear-gradient() for over a decade, so clean unprefixed CSS is recommended.

Performance & Dark Mode Tips

Animating box-shadow directly on hover can trigger expensive browser repaints on large cards. For 60fps hover transitions, render the elevated shadow on a ::after pseudo-element and animate its opacity from 0 to 1 instead. On dark backgrounds, soft black shadows become nearly invisible - pair them with a subtle 1px top border or light inset highlight (rgba(255,255,255,0.08)) to preserve card separation.

Please read the privacy policy (agreement of the cookies usage, other websites embedded content, etc.). If you continue to use the site, we will assume that you agree with our privacy policy.
OkPrivacy Policy