Home  >  Article  >  Web Front-end  >  How to Achieve a CSS Glass Blur Effect on an Overlay?

How to Achieve a CSS Glass Blur Effect on an Overlay?

Barbara Streisand
Barbara StreisandOriginal
2024-11-24 21:37:21827browse

How to Achieve a CSS Glass Blur Effect on an Overlay?

Applying CSS Glass/Blur Effect to an Overlay

Q: Implementing a blur effect on a semi-transparent overlay

A web developer is facing difficulties in applying a blur effect to an overlay div, making the content behind the div appear blurred.

Previous Attempt:

The developer attempted to implement the effect using the following CSS:

#overlay {
    filter:blur(4px);
    -o-filter:blur(4px);
    -ms-filter:blur(4px);
    -moz-filter:blur(4px);
    -webkit-filter:blur(4px);
}

However, this approach was unsuccessful.

Revised Solution:

For a simpler and more modern solution, the developer can utilize the backdrop-filter property:

#overlay {
    backdrop-filter: blur(6px);
}

Browser Support:

Note that browser support for backdrop-filter is not comprehensive. However, for many use cases, a blur effect is not critical.

The above is the detailed content of How to Achieve a CSS Glass Blur Effect on an Overlay?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn