Glassmorphism Effects with HTML & CSS

Web Design & Web Development

Demo

Sponsored links

 

Code

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Glassmorphism Effects</title>
    <link rel="stylesheet" type="text/css" href="https://demo.plantpot.works/assets/css/normalize.css">
    <link rel="stylesheet" href="https://use.typekit.net/opg3wle.css">
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <div id="container">
      <div class="box">
        <div class="card">
          <h1>GLASS<br>MORPHISM<br>EFFECTS</h1>
        </div>
        <span class="square-01"></span>
        <span class="square-02"></span>
      </div>
    </div>
  </body>
</html>

CSS

@charset "utf-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  background-image: linear-gradient(135deg, #f40077, #ee96D4);
  font-family: futura-pt, sans-serif;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  padding: 20px;
  overflow: hidden;
}
.box {
  position: relative;
  width: 100%;
  max-width: 400px;
}
.card {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 10;
  width: 100%;
  height: auto;
  padding: 30px 0;
  border: solid 1px rgba(255, 255, 255, .5);
  border-radius: 8px;
  box-shadow: 4px 4px 10px rgba(0, 0, 0, .1),
             -4px -4px 10px rgba(0, 0, 0, .1);
  background-color: rgba(255, 255, 255, .1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
h1 {
  z-index: 100;
  margin: 0;
  color: #fff;
  font-size: 3rem;
  letter-spacing: 2px;
  text-align: center;
}
.square-01 {
  position: absolute;
  top: -75px;
  right: -75px;
  z-index: 1;
  width: 150px;
  height: 150px;
  background-color: #ffc900;
}
.square-02 {
  position: absolute;
  bottom: -75px;
  left: -75px;
  z-index: 1;
  width: 150px;
  height: 150px;
  background-color: #fe8500;
}
@media screen and (max-width: 480px) {
  .box {
    max-width: 300px;
  }
  h1 {
    font-size: 2rem;
  }
}