The drop-shadow() function is an inbuilt function which is used to apply a filter to the image to set the shadow of the image. The drop-shadow() function creates a blurred shadow in a given offset and color.
Syntax:
drop-shadow( offset-x offset-y blur-radius spread-radius color )
Parameters: This function accepts five parameters as mentioned above and described below:
- offset-x: This parameter sets the horizontal offset of an image. The positive value creates the offset to the right side and negative value creates the offset to the left side.
- offset-y: This parameter sets the vertical offset of an image. The positive value creates the offset to the bottom side and negative value creates the offset to the top side.
- blur-radius: It sets the value of blur radius. It is an optional parameter.
- spread-radius: It sets the value of spread radius. It is an optional parameter.
- color: It sets the color of drop shadow. Its optional parameter.
Below examples illustrate the drop-shadow() function in CSS:
Example 1:
html
<!DOCTYPE html>
< html >
< head >
< title >CSS drop-shadow() Function</ title >
< style >
h1 {
color:green;
}
body {
text-align:center;
}
.drop_shadow_effect {
filter: drop-shadow(10px 10px 10px yellow)
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >CSS drop-shadow() function</ h2 >
< img class = "drop_shadow_effect" src =
alt = "GeeksforGeeks logo" >
</ body >
</ html >
|
Output:
Example 2:
html
<!DOCTYPE html>
< html >
< head >
< title >CSS drop-shadow() Function</ title >
< style >
h1 {
color:green;
}
body {
text-align:center;
}
.drop_shadow_effect {
filter: drop-shadow(-10px -10px 20px yellow)
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >CSS drop-shadow() function</ h2 >
< img class = "drop_shadow_effect" src =
alt = "GeeksforGeeks logo" >
</ body >
</ html >
|
Output:
Supported Browsers: The browsers supported by drop-shadow() function are listed below:
- Google Chrome 18
- Edge 12
- Internet Explorer not supported
- Firefox 35
- Safari 6
- Opera 15
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
07 Jun, 2023
Like Article
Save Article