Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • CSS Tutorial
  • CSS Exercises
  • CSS Interview Questions
  • CSS Selectors
  • CSS Properties
  • CSS Functions
  • CSS Examples
  • CSS Cheat Sheet
  • CSS Templates
  • CSS Frameworks
  • Bootstrap
  • Tailwind
  • CSS Formatter
Open In App
Next Article:
How to create a Spotlight Effect using HTML and CSS ?
Next article icon

How to Make a Glass/Blur Effect Overlay using HTML and CSS?

Last Updated : 25 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

To give a background blur effect on an overlay, the CSS backdrop-filter: blur() property is used with ::before pseudo-element. The backdrop-filter: blur() property gives the blur effect on the box or any element where it is desired and “before” is used to add the blurred background without applying any extra markup.

HTML Code: In this section, we will use HTML code to design the basic structure of the web page.

HTML
<!DOCTYPE html> <html>  <head>     <meta charset="utf-8">     <title>         How to make a CSS glass/blur         effect work for an overlay?     </title>          <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">  </head>  <body>     <section>         <div class="layout">             <h1>GeeksforGeeks</h1>                          <p class="py-2">                 It is a computer science portal for geeks.                 It is a platform where you can learn and                 practice programming problems. It contains                 programming content, web technology content,                 and some other domain content also.             </p>              <button class="btn btn-danger">                 Button             </button>         </div>     </section> </body>  </html> 

CSS Code: In this section, we will use some CSS properties to make a glass/blur effect overlay using HTML and CSS.

CSS
/* CSS code */ body {     margin: 0;     padding: 0; }  section {     display: flex;     background: #001923;     justify-content: center;     align-items: center;     width: 100%;     min-height: 100vh; }  section .layout {     position: relative;     width: 100%;     max-width: 600px;     padding: 50px;     box-shadow: 0 10px 20px rgba(0, 0, 0, .1);     background: rgba(255, 255, 255, 0.1);     backdrop-filter: blur(20px);     border: 1px solid rgba(255, 255, 255, 0.25);     border-radius: 10px; }  section .layout::before {     content: '';     position: absolute;     top: 0;     bottom: 0;     left: 0;     right: 0; }  section .layout h1 {     position: relative;     text-align: center;     color: rgb(36, 168, 36); }  section .layout p {     position: relative;     color: #fff; }  section .layout button {     position: relative; } 

Combined Code: In this section, we will combine the above two sections of code (HTML and CSS code) to make a glass/blur effect overlay.

HTML
<!DOCTYPE html> <html>  <head>     <meta charset="utf-8">     <title>         How to make a CSS glass/blur         effect work for an overlay?     </title>      <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">      <style>         body {             margin: 0;             padding: 0;         }          section {             display: flex;             background: #001923;             justify-content: center;             align-items: center;             width: 100%;             min-height: 100vh;         }          section .layout {             position: relative;             width: 100%;             max-width: 600px;             padding: 50px;             box-shadow: 0 10px 20px rgba(0, 0, 0, .1);             background: rgba(255, 255, 255, 0.1);             backdrop-filter: blur(20px);             border: 1px solid rgba(255, 255, 255, 0.25);             border-radius: 10px;         }          section .layout::before {             content: '';             position: absolute;             top: 0;             bottom: 0;             left: 0;             right: 0;         }          section .layout h1 {             position: relative;             text-align: center;             color: rgb(36, 168, 36);         }          section .layout p {             position: relative;             color: #fff;         }          section .layout button {             position: relative;         }     </style> </head>  <body>     <section>         <div class="layout">             <h1>GeeksforGeeks</h1>              <p class="py-2">                 It is a computer science portal for geeks.                 It is a platform where you can learn and                 practice programming problems. It contains                 programming content, web technology content,                 and some other domain content also.             </p>              <button class="btn btn-danger">                 Button             </button>         </div>     </section> </body>  </html> 

Output: 

HTML is the foundation of web pages and is used for webpage development by structuring websites and web apps. You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.

CSS is the foundation of web pages and is used for webpage development by styling websites and web apps. You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.



Next Article
How to create a Spotlight Effect using HTML and CSS ?

T

tushar18bcs1063
Improve
Article Tags :
  • CSS
  • HTML
  • Web Technologies
  • Web Templates

Similar Reads

  • Apply Glowing Effect to the Image using HTML and CSS
    While surfing most of the websites you have seen some special effects which can be seen on various images while putting your cursor over them. So, in this article, we are going to implement the same. We can use such images as a card for our website.  In this article, you’re going to learn how to app
    2 min read
  • How to Create an Image Overlay Icon using HTML and CSS ?
    Image overlay Icon can be an impressive addition to interactive detail or a set of features for your website. This article content will divide the task into two sections, the first section creating the structure and attach the link for the icon. In the second section, we will design the structure us
    3 min read
  • How to make photo sliding effect using HTML and CSS ?
    It is an easy and amazing animation effect created with HTML and CSS, where the photos are moving horizontally one by one like a roller. When the mouse pointer comes upon the photo then the specific photo stops moving. Approach: The basic idea of these animation comes from the hover effect of CSS an
    5 min read
  • How to create a Spotlight Effect using HTML and CSS ?
    In this article, we are going to create a spotlight effect over the image when we hover over it. This is mainly based on HTML, CSS and JavaScript. The below steps have to be followed to create this effect. HTML Section: In this section, we will create a container elements for the background image an
    4 min read
  • How to Create Image Overlay Hover using HTML & CSS ?
    In this article, we will go over 5 different types of overlays: left, right, top, bottom, and fade. You are going to need two divs. One will be your overlay div, containing what will show up once the user hovers over the image, and the other will be a container that holds both the image and its over
    6 min read
  • How to Create Engraved Text Effect using HTML and CSS ?
    The engraved text effect is an effect that you can use in your websites as a heading or a sub-heading to make it look more pleasing and attractive. Approach: The engraved text effect can be easily generated using HTML and CSS. First we will create a basic text using HTML and then by using the CSS te
    2 min read
  • How to create Neumorphism Effect using HTML and CSS ?
    Neumorphism (neomorphism) is a modern way of styling web-elements of any web-page and providing a 3D effect. This animation effect can be easily generated by using HTML and CSS. Box-shadow property of CSS can be used to implemented Neumorphism. It is used to add a dark shadow to one side and a light
    2 min read
  • How to Create Floating Box Effect using HTML and CSS ?
    The floating box effect is a classical example of a custom box-shadow technique. In this technique, we create realistic-looking shadows without using the box-shadow property that is provided by the CSS. Approach: The approach is to use after selector to use create shadow using the blur function. HTM
    2 min read
  • How to create an Image Overlay Zoom Effect on hover using CSS ?
    Image Overlay Zoom Effect on hover can be done by using CSS. This effect is used in web design for user attention to images by highlighting the content or text, and to improve the overall look of a website by adding dynamic visual effects. We have given a Zoom effect to the text and image when the u
    2 min read
  • How to create reflection effect using HTML and CSS ?
    The reflection effect is one of the coolest effects that one can use in his/her website. It is a type of informal effect so it is highly recommended not to use it any professional project. You can use it in your personal projects and maybe your portfolio to show your creativity. In this effect, we t
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences