Glassmorphism design in Css

 Glassmorphism design in Css

preview

This is a mini web project to demonstrate Glassmorphism design using Html and CSS only.

What is Glassmorphism?
Glassmorphism design is a new, clean and modern UI design where most of the developers prefer to use in their web pages. We basically add a blur effect to the element so that it looks like a glass and all the elements behind it looks visually blur.

This design is quite easy to achieve by adding just one css property as below:
  • backdrop-filter: blur(value)
Please check the code below and get started 💻.

Html code
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Glassmorphism Design</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="container">
      <div class="ball ball1"></div>
      <div class="ball ball2"></div>
      <div class="ball ball3"></div>
      <div class="box">
        <h1 class="title">
          <span class="icon"></span><br />
          Glassmorphism Design
        </h1>
        <p class="text">
          Using html and css only.
        </p>
      </div>
    </div>
  </body>
</html>

Css code
/* global styling */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100vh;
  font-family: sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #4c91e2;
}

.container {
  position: relative;
}

.box {
  padding: 2rem;
  background-color: rgba(255, 255, 255, 0.3);
  border: 1px solid #ccc;
  border-radius: 10px;
  text-align: center;
  color: #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
}

h1.title {
  margin-bottom: 1rem;
}

span.icon {
  font-size: 3rem;
}

.ball {
  position: absolute;
  width: 100px;
  height: 100px;
  background: linear-gradient(-45deg, lightblue, #87b9fa);
  border-radius: 50%;
}

.ball1 {
  top: -4rem;
  left: 2rem;
  transform: scale(0.7);
  z-index: 1;
}

.ball2 {
  right: -3rem;
  bottom: -3rem;
  transform: scale(1.5);
  z-index: -1;
}

.ball3 {
  bottom: 1rem;
  left: -3rem;
  z-index: -1;
}

That is all! Thank you for visiting my blog.
Post a Comment (0)
Previous Post Next Post