Home > Web Front-end > CSS Tutorial > How to Achieve a Blurred Glass Effect Without Relying on `backdrop-filter`?

How to Achieve a Blurred Glass Effect Without Relying on `backdrop-filter`?

DDD
Release: 2024-10-27 20:03:30
Original
656 people have browsed it

How to Achieve a Blurred Glass Effect Without Relying on `backdrop-filter`?

A Blurred Alternative to CSS's Elusive backdrop-filter

Despite its captivating effect, CSS's backdrop-filter remains elusive, with limited browser support as of July 1, 2016. While we eagerly await its full implementation, let's explore a workaround that can bring us closer to the desired blurred glass effect.

A Transparent Fallback

For browsers that lack backdrop-filter support, a slightly transparent background can mimic the frosted glass effect. The following code provides a simple fallback:

<code class="css">/* slightly transparent fallback */
.backdrop-blur {
  background-color: rgba(255, 255, 255, .9);
}</code>
Copy after login

Leveraging Browser Support

For browsers that do support backdrop-filter, we can take advantage of its blurring capabilities. Here's an augmented version of the CSS code that caters to this scenario:

<code class="css">/* if backdrop support: very transparent and blurred */
@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
  .backdrop-blur {
    background-color: rgba(255, 255, 255, .5);
    -webkit-backdrop-filter: blur(2em);
    backdrop-filter: blur(2em);
  }
}</code>
Copy after login

This code ensures that the blurred effect is applied in supported browsers, while the transparent fallback degrades gracefully for those that don't.

Examples: Seeing the Blur in Action

Without backdrop-filter support, the element displays with a slightly transparent background, as illustrated by the following image:

[Insert image of transparent fallback effect]

With backdrop-filter support, the blurred glass effect takes hold, as showcased in the following image:

[Insert image of blurred effect]

Conclusion

The backdrop-filter workaround presented here provides a practical solution for achieving a blurred glass effect on web elements, regardless of browser support. While we anticipate the full availability of backdrop-filter in the future, this technique offers a valuable alternative for enhancing the user experience.

The above is the detailed content of How to Achieve a Blurred Glass Effect Without Relying on `backdrop-filter`?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template