CSS backdrop-filter



The CSS property backdrop-filter helps you in adding graphical effects to the area behind an element, i.e., to the backdrop of an element. As this property add the effects such as blurring, behind the element, the element needs to be fully or partially transparent for the effect to be visible.

Possible Values

The backdrop-filter CSS property can have one of the following values:

  • none: No filter to be applied to the backdrop of the element.

  • <filter-function-list>: It is a space-separated list of <filter-function>s, which will be applied to the backdrop of an element. The functions that are included are: blur(), brightness(), contrast(), drop-shadow(), grayscale(), hue-rotate(), invert(), opacity(), saturate(), and sepia().

Applies To

All html elements. In SVG, it applies to container elements excluding the <defs> element and all graphics elements

Syntax

/* Keyword Value */
backdrop-filter: none;

/* <filter-function> values */
backdrop-filter: blur(4px);
backdrop-filter: brightness(80%);
backdrop-filter: contrast(20%);
backdrop-filter: drop-shadow(2px 2px 8px red);
backdrop-filter: grayscale(60%);
backdrop-filter: hue-rotate(100deg);
backdrop-filter: invert(80%);
backdrop-filter: opacity(40%);
backdrop-filter: saturate(90%);
backdrop-filter: sepia(70%);

/* Multiple filters */
backdrop-filter: blur(4px) saturate(90%);

CSS backdrop-filter - none Value

The following example demonstrates the use of backdrop-filter: none property which adds no filter to the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/red-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .nofilter-box {
      background-color: rgba(255, 255, 255, 0.4);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: none CSS Property</h1>

   <div class="background-img">
   <div class="blur-box">
      <p>backdrop-filter: none</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - blur() Value

The following example demonstrates the use of backdrop-filter: blur() property to blur the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/scenery2.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .blur-box {
      background-color: rgba(255, 255, 255, 0.4);
      -webkit-backdrop-filter: blur(15px);
      backdrop-filter: blur(15px);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: blur() CSS Property</h1>

   <div class="background-img">
   <div class="blur-box">
      <p>backdrop-filter: blur(15px)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - brightness() Value

The following example demonstrates the use of backdrop-filter: brightness() property to brighten the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/orange-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .bright-box {
      background-color: rgba(255, 255, 255, 0.4);
      -webkit-backdrop-filter: brightness(50%);
      backdrop-filter: brightness(50%);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: brightness() CSS Property</h1>

   <div class="background-img">
   <div class="bright-box">
      <p>backdrop-filter: brightness(50%)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - contrast() Value

The following example demonstrates the use of backdrop-filter: contrast() property to add contrast to the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/orange-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .contrast-box {
      background-color: rgba(255, 255, 255, 0.4);
      -webkit-backdrop-filter: contrast(10%);
      backdrop-filter: contrast(10%);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: contrast() CSS Property</h1>

   <div class="background-img">
   <div class="contrast-box">
      <p>backdrop-filter: contrast(10%)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - grayscale() Value

The following example demonstrates the use of backdrop-filter: grayscale() property to add grayscale effect to the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/orange-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .gray-box {
      background-color: rgba(255, 255, 255, 0.4);
      -webkit-backdrop-filter: grayscale(70%);
      backdrop-filter: grayscale(70%);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: grayscale() CSS Property</h1>

   <div class="background-img">
   <div class="gray-box">
      <p>backdrop-filter: grayscale(70%)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - hue-rotate() Value

The following example demonstrates the use of backdrop-filter: hue-rotate() property to add the hue-rotate effect to the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/orange-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .hue-box {
      background-color: rgba(255, 255, 255, 0.4);
      -webkit-backdrop-filter: hue-rotate(120deg);
      backdrop-filter: hue-rotate(120deg);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: hue-rotate() CSS Property</h1>

   <div class="background-img">
   <div class="hue-box">
      <p>backdrop-filter: hue-rotate(120deg)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - invert() Value

The following example demonstrates the use of backdrop-filter: invert() property to add the invert effect to the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/orange-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .invert-box {
      background-color: rgba(255, 255, 255, 0.4);
      -webkit-backdrop-filter: invert(70%);
      backdrop-filter: invert(70%);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: invert() CSS Property</h1>

   <div class="background-img">
   <div class="invert-box">
      <p>backdrop-filter: invert(70%)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - opacity() Value

The following example demonstrates the use of backdrop-filter: opacity() property to adjust the transparency effect of the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/red-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .opacity-box {
      background-color: rgba(255, 255, 255, 0.6);
      -webkit-backdrop-filter: opacity(10%);
      backdrop-filter: opacity(10%);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: opacity() CSS Property</h1>

   <div class="background-img">
   <div class="opacity-box">
      <p>backdrop-filter: opacity(10%)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - sepia() Value

The following example demonstrates the use of backdrop-filter: sepia() property to add the sepia effect to the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/red-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .sepia-box {
      background-color: rgba(255, 255, 255, 0.6);
      -webkit-backdrop-filter: sepia(90%);
      backdrop-filter: sepia(90%);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: sepia() CSS Property</h1>

   <div class="background-img">
   <div class="sepia-box">
      <p>backdrop-filter: sepia(90%)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - saturate() Value

The following example demonstrates the use of backdrop-filter: saturate() property to add the saturation effect to the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/red-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .saturate-box {
      background-color: rgba(255, 255, 255, 0.6);
      -webkit-backdrop-filter: saturate(180%);
      backdrop-filter: saturate(180%);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: saturate() CSS Property</h1>

   <div class="background-img">
   <div class="saturate-box">
      <p>backdrop-filter: saturate(180%)</p>
   </div>
   </div>
</body>
</html>

CSS backdrop-filter - Using Multiple Values

The following example demonstrates the use of backdrop-filter: blur() grayscale() property to add blur and grayscale effects to the backdrop of the element:

<html>
<head>
<style>
   .background-img {
      background: url(images/orange-flower.jpg) no-repeat center;
      background-size: cover;
      align-items: center;
      display: flex;
      justify-content: center;
      height: 400px;
      width: 400px;
   }

   .multi-box {
      background-color: rgba(255, 255, 255, 0.4);
      -webkit-backdrop-filter: blur(2px) grayscale(70%);
      backdrop-filter: blur(2px) grayscale(70%);
      padding: 20px;
      margin: 30px;
      font-weight: bold;
   }
</style>
</head>
<body>
   <h1>backdrop-filter: blur() grayscale() CSS Property</h1>

   <div class="background-img">
   <div class="multi-box">
      <p>backdrop-filter: blur(2px) grayscale(70%)</p>
   </div>
   </div>
</body>
</html>
Advertisements