Open In App

CSS | backdrop-filter Property

The CSS backdrop-filter property is used to apply effects to the area behind an element. This is unlike the filter property where it applies the effect to the whole element. It can be used to eliminate the use of an extra element to style the background separately. 

Syntax:



backdrop-filter: blur() | brightness() | contrast() | drop-shadow() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia() | none | initial | inherit

Property Values:



Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
 
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;
        }
        .foreground {
            backdrop-filter: blur(5px);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected
            by backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: brightness(25%);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected
            by backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
 
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: contrast(20%);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: drop-shadow(20px 10px red);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: grayscale(75%);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: hue-rotate(180deg);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: invert(100%);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: opacity(50%);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: saturate(50%);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: sepia(100%);
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
 
    <b>CSS | backdrop-filter</b>
 
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: none;
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>CSS | backdrop-filter</title>
     
    <style>
        .container {
            background-image: url(
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100px;
            width: 360px;    
        }
        .foreground {
            backdrop-filter: initial;
            padding: 2px;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
     
    <b>CSS | backdrop-filter</b>
     
    <div class="container">
        <div class="foreground">
            This text is not affected by
            backdrop-filter.
        </div>
    </div>
</body>
 
</html>

 

Supported Browsers: The browsers supported by backdrop-filter property are listed below:


Article Tags :