backdrop-filter

A propriedade CSS backdrop-filter permite que você aplique efeitos gráficos, como desfoque ou mudança de cores, na área ao fundo de um elemento. Como ela se aplica a tudo que fica atrás do elemento, é preciso deixá-lo (ou o seu plando de fundo) ao menos parcialmente transparente para poder ver o efeito em ação.

/* Valor de palavra-chave */
backdrop-filter: none;

/* Filtro com URL para SVG */
backdrop-filter: url(commonfilters.svg#filter);

/* Valores <filter-function> */
backdrop-filter: blur(2px);
backdrop-filter: brightness(60%);
backdrop-filter: contrast(40%);
backdrop-filter: drop-shadow(4px 4px 10px blue);
backdrop-filter: grayscale(30%);
backdrop-filter: hue-rotate(120deg);
backdrop-filter: invert(70%);
backdrop-filter: opacity(20%);
backdrop-filter: sepia(90%);
backdrop-filter: saturate(80%);

/* Vários filtros */
backdrop-filter: url(filters.svg#filter) blur(4px) saturate(150%);

/* Valores globais */
backdrop-filter: inherit;
backdrop-filter: initial;
backdrop-filter: unset;

Sintaxe

Valores

none
Nenhum filtro é aplicado ao plano de fundo.
<filter-function-list>
Uma lista de <filter-function>s separadas por espaços ou um filtro SVG que será aplicado ao plano de fundo.

Definição formal

Initial valuenone
Aplica-se aall elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements
Inheritednão
Computed valueas specified
Animation typea filter function list

Sintaxe formal

backdrop-filter = 
none |
<filter-value-list>

<filter-value-list> =
[ <filter-function> | <url> (en-US) ]+

<filter-function> =
<blur()> |
<brightness()> |
<contrast()> |
<drop-shadow()> |
<grayscale()> |
<hue-rotate()> |
<invert()> |
<opacity()> |
<sepia()> |
<saturate()>

<blur()> =
blur( <length> (en-US)? )

<brightness()> =
brightness( <number-percentage>? )

<contrast()> =
contrast( <number-percentage>? )

<drop-shadow()> =
drop-shadow( <color>? &&
<length> (en-US){2,3} )

<grayscale()> =
grayscale( <number-percentage>? )

<hue-rotate()> =
hue-rotate( [ <angle> (en-US) | <zero> ]? )

<invert()> =
invert( <number-percentage>? )

<opacity()> =
opacity( <number-percentage>? )

<sepia()> =
sepia( <number-percentage>? )

<saturate()> =
saturate( <number-percentage>? )

<color> =
<absolute-color-base> |
currentcolor |
<system-color> |
<device-cmyk()>

<absolute-color-base> =
<hex-color> (en-US) |
<named-color> |
transparent |
<rgb()> |
<rgba()> |
<hsl()> |
<hsla()> |
<hwb()> |
<lab()> |
<lch()> |
<oklab()> |
<oklch()> |
<color()>

<device-cmyk()> =
device-cmyk( <cmyk-component>{4} [ / <alpha-value> ]? )

<rgb()> =
rgb( [ <percentage> (en-US) | none ]{3} [ / [ <alpha-value> | none ] ]? ) |
rgb( [ <number> | none ]{3} [ / [ <alpha-value> | none ] ]? )

<hsl()> =
hsl( [ <hue> | none ] [ <percentage> (en-US) | none ] [ <percentage> (en-US) | none ] [ / [ <alpha-value> | none ] ]? )

<hwb()> =
hwb( [ <hue> | none ] [ <percentage> (en-US) | none ] [ <percentage> (en-US) | none ] [ / [ <alpha-value> | none ] ]? )

<lab()> =
lab( [ <percentage> (en-US) | <number> | none ] [ <percentage> (en-US) | <number> | none ] [ <percentage> (en-US) | <number> | none ] [ / [ <alpha-value> | none ] ]? )

<lch()> =
lch( [ <percentage> (en-US) | <number> | none ] [ <percentage> (en-US) | <number> | none ] [ <hue> | none ] [ / [ <alpha-value> | none ] ]? )

<oklab()> =
oklab( [ <percentage> (en-US) | <number> | none ] [ <percentage> (en-US) | <number> | none ] [ <percentage> (en-US) | <number> | none ] [ / [ <alpha-value> | none ] ]? )

<oklch()> =
oklch( [ <percentage> (en-US) | <number> | none ] [ <percentage> (en-US) | <number> | none ] [ <hue> | none ] [ / [ <alpha-value> | none ] ]? )

<color()> =
color( <colorspace-params> [ / [ <alpha-value> | none ] ]? )

<cmyk-component> =
<number> |
<percentage> (en-US)

<alpha-value> =
<number> |
<percentage> (en-US)

<hue> =
<number> |
<angle> (en-US) |
none

<colorspace-params> =
<predefined-rgb-params> |
<xyz-params>

<predefined-rgb-params> =
<predefined-rgb> [ <number> | <percentage> (en-US) | none ]{3}

<xyz-params> =
<xyz-space> [ <number> | none ]{3}

<predefined-rgb> =
srgb |
srgb-linear |
display-p3 |
a98-rgb |
prophoto-rgb |
rec2020

<xyz-space> =
xyz |
xyz-d50 |
xyz-d65

Exemplo

CSS

.box {
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  font-family: sans-serif;
  text-align: center;
  line-height: 1;
 -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  max-width: 50%;
  max-height: 50%;
  padding: 20px 40px;
}

html,
body {
  height: 100%;
  width: 100%;
}

body {
  background-image: url(https://picsum.photos/id/1080/6858/4574);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

.container {
  align-items: center;
  display: flex;
  justify-content: center;
  height: 100%;
  width: 100%;
}

HTML

<div class="container">
  <div class="box">
    <p>backdrop-filter: blur(10px)</p>
  </div>
</div>

Resultado

Especificações

Specification
Filter Effects Module Level 2
# BackdropFilterProperty

Compatibilidade com navegadores

BCD tables only load in the browser

Veja também