CSS Property: box-shadow
[this page | pdf | back links]
The CSS (CSS3) box-shadow property applies one or
more shadows to an element. The property is a comma-separated list of shadows,
each specified by 2 to 4 length values, an optional colour and an optional
inset keyword. If a length is omitted then it is taken to be zero.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
box-shadow parameter
|
See below
|
none
|
(default value). No shadow
is displayed
|
Default Value:
|
none
|
JavaScript syntax:
|
e.g. object.style.boxShadow="5px 10px 15px red
inset"
|
Inherited:
|
No
|
Animatable:
|
Yes
|
The parameters of the
box-shadow parameter are:
Value
|
Description
|
h-shadow
|
Position of horizontal
shadow (can be negative)
|
v-shadow
|
Position of vertical
shadow (can be negative)
|
blur
|
Optional. Blur distance
|
spread
|
Optional. Size of
shadow (can be negative)
|
color
|
Optional (for most
browsers). Shadow CSS colour.
Default value is black.
|
inset
|
Optional. Changes
shadow from an outer shadow to an inner shadow
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
p {border: thin solid black; width: 200px}
p.x1 {box-shadow: 5px 10px 15px red inset;}
</style>
</head>
<body>
<p>1. Element with default property</p>
<p class="x1">2. Element set using in-file HTML style</p>
<p id="x2">3. Element set using JavaScript</p>
<script>
document.getElementById("x2").style.boxShadow = "5px 10px 15px red inset";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyBoxShadow() {
var x = document.createElement("DIV"); x.style.boxShadow = "5px 10px 15px red inset"; return (window.getComputedStyle(x, null).boxShadow == "5px 10px 15px red inset");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties