Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • 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
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • jQuery
  • AngularJS
  • ReactJS
  • Next.js
  • React Native
  • NodeJS
  • Express.js
  • MongoDB
  • MERN Stack
  • PHP
  • WordPress
  • Bootstrap
  • Tailwind
  • CSS Frameworks
  • JS Frameworks
  • Web Development
Open In App
Next Article:
Design a Frosted Glass Effect using HTML and CSS
Next article icon

Design a Frosted Glass Effect using HTML and CSS

Last Updated : 04 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will implement a frosted glass effect using the bootstrap 4 card class. The below image is the final output that you will get as the final result of this article.

frosted-copy


Approach:

1. Styling the body:

Let's first set the background for your webpage. Write the below code under your head tag inside your <style> tag. If you have already set your background property (which you would have) then skip to the next section. If not, here you go.


CSS
body {      background-image: url('background.jpg');      background-repeat: no-repeat;      background-size: 100%;      background-attachment: fixed; } 

You can read about the above properties here


2. Frost glass card:

Under the style tag, use the following code,

CSS
.card {       box-shadow: 0 0 5px 0 ;       background: inherit;       backdrop-filter: blur(10px);       <!--margin: 100px; according to your need--> } 

So what do we have here,

  • box-shadow: This property is used to give a shadow-like effect to the frames of an element.
  • background: Use this to make the element transparent and have the same background as your webpage (in the body class its necessary to have "background-attachment: fixed,")
  • backdrop-filter: Use this to apply effects to the area behind an element. (Read this as well) Basically, this is the property that is reducing a lot of CSS styling here.
  • margin: Margin and padding are according to your need.

Note: There have been issues with Mozilla's browser Firefox and in cases, the backdrop-filter doesn't work properly, chrome and edge work fine.

3. <div> in body:

HTML
<body>     <div class="container">         <div class="card card-body" style="justify-content: center;">             <!--Contents <h1 >_______</h1> -->         </div>     </div> </body> 

Final Code:

HTML
<!DOCTYPE html> <html lang="en">  <head>     <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">      <style>         body {             background-image: url( "https://media.geeksforgeeks.org/wp-content/uploads/20200318142240/Bootstrap5.png");             background-repeat: no-repeat;             background-size: 100%;             background-attachment: fixed;         }                  h1 {             color: white;             height: 250px;             display: flex;             justify-content: center;             align-items: center;         }                  .card {             top: 50%;             box-shadow: 0 0 5px 0;             background: inherit;             backdrop-filter: blur(10px);             margin: 100px;             text-align: center;         }     </style> </head>  <body>      <div class="container">         <div class="card card-body"              style="justify-content: center;">             <h1>GeeksforGeeks</h1>         </div>     </div> </body>  </html> 

Output:


Next Article
Design a Frosted Glass Effect using HTML and CSS

K

kumar0rishav
Improve
Article Tags :
  • Technical Scripter
  • Web Technologies
  • Web Templates
  • Technical Scripter 2020

Similar Reads

    Design a Layered Image Page Template using HTML and CSS
    The article provides a complete guide for creating a layered image layout using HTML and CSS. The Layered Image Page refers to a webpage design that contains layered structured visual elements using images. Here, the design contains two boxes with background images and some empty rounded boxes with
    3 min read
    How to Design Stitched Glowing Effect for Button using HTML and CSS ?
    The stitched glowing effect is generally used in the design of classical or retro-themed websites. You can also call it a Denim effect if you use blue color for the effect as it looks similar to the classic original denim. It is one of the best effect to understand the concept of radial-gradient and
    1 min read
    Design a Image Hover Effect Color Transition template using HTML and CSS
    The article uses HTML and CSS to create the template for an Image Hover Effect with Color Transition. This template adds an interactive element to your web design by smoothly transitioning colors when users hover over an image. You can create a dynamic effect that enhances visual engagement by utili
    2 min read
    Design a Overlap Block Page Template using HTML and CSS
    In this article, we will create an Overlap Block layout template using HTML & CSS. The Overlap Block Layout is a design concept where multiple elements or blocks on a webpage visually overlap with one another. This layout frequently uses CSS's z-index property to regulate the order in which item
    3 min read
    Design a Offer Box With Ribbon template using HTML and CSS
    To highlight special offers, discounts, or promotions, offer boxes with ribbons are a common graphic element seen in marketing and promotional materials. Usually, it is just a box or container with the offer inside that is decorated with ribbon to make it look festive and appealing. The ribbon serve
    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