The boxShadow
property sets or gets the drop-shadows of a box element.
boxShadow |
Yes | 10.0 | Yes | Yes | Yes |
Return the boxShadow property:
var v = object.style.boxShadow
Set the boxShadow property:
object.style.boxShadow='none|h-shadow v-shadow blur spread color |inset|initial|inherit'
Default Value: | none |
---|---|
Return Value: | A string representing the box-shadow property |
CSS Version | CSS3 |
The following code shows how to add a box-shadow to a div element.
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {<!-- w w w . j av a 2 s . c o m-->
position: absolute;
width: 100px;
height: 100px;
background-color: coral;
color: white;
}
</style>
</head>
<body>
<button onclick="myFunction()">test</button>
<div id="myDIV">myDIV</div>
<script>
function myFunction() {
document.getElementById("myDIV").style.boxShadow = "10px 20px 30px red";
}
</script>
</body>
</html>
The code above is rendered as follows: