⚠️ This lesson is retired and might contain outdated information.

Use the "filter" property in CSS to create blur effects on elements

Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 2 years ago

The CSS "filter" property adds visual effects to an element. Consequently, you can create the "blur" effect on an element by using the syntax, "filter: blur()" in CSS. The "blur" filter creates a gaussian blur on the element.

By specifying a number of pixels for the screen to blend into each other, you can change the intensity of the blur. The larger the value in pixels, the more intense the blur.

Hiro Nishimura: [0:00] Here, we have an image set to class="effect". In the style.css document, we'll create a hover effect for the image. To create the blur effect on an element we use the filter property. We can set the amount of blur that occurs using pixels. Let's try 5px.

[0:15] Now, if we refresh the page, the image should blur on mouseover because we set the blur filter effect to occur on hover. The larger the value in pixels we put in, the blurrier the element will be.

[0:26] Let's compare how a bigger pixel value influences how blurry an element becomes. I'll create another CSS class, this time named effect2. I will set the blur to 50px. Coming back to index.html, I insert another image with the class set to effect2.

[0:42] When we refresh the browser, we see that now there are two images, one set to the effect class with 5px blur and the other set to effect2 class with 50px blur.

[0:52] This works on other types of elements as well, like text. Let's put in some text and set it to the effect class. When we refresh the browser, we can see that this text blurs on hover, just like the images.

[1:02] We learned how to create the blur effect on an element in CSS by using the filter property and how to adjust how blurry we want the element to be using pixels. The larger the number of pixels, the blurrier the element becomes, as we can see in the example we worked with.

egghead
egghead
~ 33 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today