3
Answers

How to add a shadow to an element in CSS ?

Photo of LAVANYA M

LAVANYA M

2y
678
1

Help me on how to add a shadow to an element in CSS.

Answers (3)

0
Photo of Mohamed Azarudeen Z
133 13.9k 197.1k 2y

Hi 

try this

.my-element {
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
Accepted
1
Photo of Tuhin Paul
39 34.6k 314.4k 2y

Below are the steps to add a shadow to an element in CSS:

1. Select the element you want to add a shadow to.
2. Add the following CSS property to the element:

box-shadow: <h-shadow> <v-shadow> <blur-radius> <spread-radius> <color>;

<h-shadow> is the horizontal offset of the shadow.
<v-shadow> is the vertical offset of the shadow.
<blur-radius> is the blur radius of the shadow.
<spread-radius> is the spread radius of the shadow.
<color> is the color of the shadow.


 

0
Photo of Deepak Rawat
122 15k 847.5k 2y
<!DOCTYPE html>
<html>
<head>
<style> 
div {
  width: 300px;
  height: 100px;
  padding: 15px;
  background-color: coral;
  box-shadow: 10px 10px 5px lightblue;
}
</style>
</head>
<body>

<h1>The box-shadow Property</h1>

<div>A div element with a 5px blurred, lightblue box-shadow.</div>

</body>
</html>