Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style boxShadow Property

Style boxShadow Property

Style Object Reference The Style object

Example

Add a shadow to a div element:

document.getElementById("myDIV").style.boxShadow="10px 20px 30px blue";

Try it »


Definition and Usage

The boxShadow property sets or returns the drop shadow of an element.


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

IE9+, Firefox, Chrome, Opera, and Safari 5.1.1 support the boxShadow property.


Syntax

Return the boxShadow property:

object

.style.boxShadow

Set the boxShadow property:

object

.style.boxShadow="none|

h-shadow v-shadow blur spread color

|inset|initial|inherit"

**Note:** The boxShadow property adds one or more drop shadows to a box. This property is a comma-separated list of shadows, where each shadow is specified by 2 to 4 length values, an optional color value, and an optional inset keyword. Omitted length values default to 0.

Attribute values

Value Description
none Default value. No shadow is displayed.
h-shadow Required. The position of the horizontal shadow. Negative values are allowed.
v-shadow Required. The position of the vertical shadow. Negative values are allowed.
blur Optional. The blur distance.
spread Optional. The size of the shadow.
color Optional. The color of the shadow. The default value is black. For a complete list of possible color values, see A CSS color value.
 **注意:** 在 Safari(在 PC 上)浏览器中,color 参数是必需的。如果您未指定颜色,则不显示阴影。 |

| inset | Optional. Changes the outer shadow (outset) to an inner shadow. | | initial | Sets this property to its default value. See initial. | | inherit | Inherits this property from the parent element. See inherit. |

Technical Details

Default value: none
Return Value: A string that represents the box-shadow property of an element.
CSS version CSS3

Related Articles

CSS Reference Manual:box-shadow property


Style Object Reference The Style object