Box-shadow-Basics

CSS Box-Shadow tutorial: the basics
Box-shadow applying to an HTML div

The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects separated by commas. A box-shadow is described by X and Y offsets relative to the element, blur and spread radius, and color.

      // x-offset y-offset blur spread colorbox-shadow: .5rem .5rem .5rem -.2rem currentColor;

inset

example of inset apply to a box shadow div

If not specified (default), the shadow is assumed to be a drop shadow (as if the box were raised above the content).
The presence of the inset keyword changes the shadow to one inside the frame (as if the content was depressed inside the box). Inset shadows are drawn inside the border (even transparent ones), above the background, but below content.

Makes it feel like there is a whole on it. Not often use.

<offset-x> <offset-y> . The only require properties.

visual representation of x and y offset provided by sailfishfirmware.com

These are two <length> values to set the shadow offset.

<offset-x>

  • Specifies the horizontal distance. Negative values place the shadow to the left of the element.

<offset-y>

  • Specifies the vertical distance. Negative values place the shadow above the element.

If both values are 0, the shadow is placed behind the element (and may generate a blur effect if <blur-radius> and/or <spread-radius> is set).

example of a blur and spread radius provided by css3.info

<blur-radius>

The larger this value, the bigger the blur, so the shadow becomes bigger and lighter.

Negative values are not allowed.

If not specified, it will be 0 (the shadow's edge is sharp).

<spread-radius>

Adds shadow by the specified length, and then blur can happen. Neg makes it move inside.

<color>

See <color> values for possible keywords and notations.

If not specified, it defaults to <currentcolor>. Safari defaults to transparent 😢, but you can fix that by using currentColor explicitly.

box-shadow: .5rem .5rem .5rem currentColor;

The currentcolor the keyword represents the value of an element's color property. This lets you use the color value on properties that do not receive it by default.

If currentcolor is used as the value of the color the property, it instead takes its value from the inherited value of the color property.

Multiple box-shadow

You cannot call two box-shadow properties for the same element.

The cascading effect will kick in, and the one run last will overwrite all others.

If you want more box-shadow, you add a comma and add more in the same property.

box-shadow: 10rem 10rem 20rem red,10rem -10rem 20rem blue,-10rem -10rem 20rem orange,-10rem 10rem 20rem purple,;

Note that the first box-shadow will be on top of the later ones.

four Box-shadow apply to a box

You can add as many as you want.

--

--