How to Add a Blur Effect to the Shadow in CSS

Blurred shadows can add a sense of depth and realism to elements on a web page.

In this CSS tutorial, we’ll show you how to create a blur effect for shadows using CSS.

First, let’s start by creating a simple box with a shadow.

We’ll use the “box-shadow” property to add the shadow to our box.

Here’s an example of the CSS code:

.box {
  width: 200px;
  height: 200px;
  background-color: #f1f1f1;
  box-shadow: 10px 10px 10px #000000;
}

In this example, we’ve created a 200px by 200px box with a gray background color.

The “box-shadow” property has four values: the horizontal offset, the vertical offset, the blur radius, and the color.

The first two values (10px, 10px) determine the position of the shadow, and the third value (10px) is the blur radius.

To add a blur effect to the shadow, we simply need to increase the blur radius value.

Here’s an example of the CSS code with a larger blur radius:

.box {
  width: 200px;
  height: 200px;
  background-color: #f1f1f1;
  box-shadow: 10px 10px 20px #000000;
}

In this case, we’ve increased the blur radius value to 20px.

This will create a more blurred shadow, giving the box a sense of depth.

You can also use the CSS filter property “blur” to add a blur effect to the shadow.

Here is an example:

.box {
  width: 200px;
  height: 200px;
  background-color: #f1f1f1;
  box-shadow: 10px 10px 10px #000000;
  filter: blur(5px);
}

In this example, the “filter” property is used to add a blur effect of 5px to the box shadow.

In conclusion, adding a blur effect to shadows in CSS can be done by increasing the blur radius value in the “box-shadow” property or by using the “filter” property with “blur” value.

This can give elements on a web page a sense of depth and realism.

Feel free to experiment with different values to find the look that works best for your project.

YouTube video

FAQs on Adding Blur Effect in CSS

Question: How do I add a shadow effect?

Answer: To add a shadow effect in CSS, use the box-shadow property and specify values for horizontal offset, vertical offset, blur radius, and color.

Question: Which property used to add a shadow or blurs to a frame?

Answer: The box-shadow property is used to add a shadow or blurs to a frame in CSS.

Question: Can you add a shadow in CSS?

Answer: Yes, you can add a shadow in CSS using the box-shadow property.

Question: How to shadow image in CSS?

Answer: To add a shadow to an image in CSS, use the box-shadow property on the image element.

Question: How do you blur a box shadow?

Answer: To blur a box shadow in CSS, use the box-shadow property and specify a value for the blur radius.

Question: What is a drop shadow effect CSS?

Answer: A drop shadow effect in CSS is created using the box-shadow property with values for horizontal offset, vertical offset, blur radius, and color to create a shadow that appears to be dropped behind an element.

Also Read:

How Do I Vertically Center Text With CSS
How to Add a Button to an Image With CSS
How to Add a Color to the Shadow in CSS
How to Add a Form to a Full-width Image With CSS


Resources and References:

  1. CSS Resources – CSS Portal
  2. CSS: Cascading Style Sheets – MDN Web Docs
  3. CSS Tutorial – W3Schools
  4. CSS – Useful Resources – Tutorialspoint