How to Create a Backdrop Blur Effect with CSS, Even in Older Browsers?

Mary-Kate Olsen
Release: 2024-10-28 13:25:02
Original
286 people have browsed it

How to Create a Backdrop Blur Effect with CSS, Even in Older Browsers?

CSS: Backdrop-Filter Polyfill

Backdrop-filter, a CSS feature enabling blur and other effects on the background of an element, remains largely unsupported in modern browsers. As an alternative, consider using a slightly transparent background as a fallback:

<code class="css">.backdrop-blur {
  background-color: rgba(255, 255, 255, .9);
}

@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 provides a transparent fallback for browsers lacking backdrop-filter support, while enabling a blurred effect in supported browsers. The CSS also allows for future CSS revisions that may introduce unprefixed backdrop-filter support.

Visualization:

[Image of transparent fallback without backdrop-filter support] [Image of blurred effect with backdrop-filter support]

The above is the detailed content of How to Create a Backdrop Blur Effect with CSS, Even in Older Browsers?. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!