Home >Web Front-end >CSS Tutorial >How to Create a Backdrop Blur Effect with CSS, Even in Older Browsers?

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

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-28 13:25:02393browse

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>

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!

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