Glassmorphism Effect with HTML & CSS

01/17/2021
Demo
Video
Code
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Glassmorphism Effect with HTML & CSS</title>
<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>EFFECT</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 {
font-family: Arial, sans-serif;
}
#container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
background-image: linear-gradient(135deg, #f40077, #ee96d4);
overflow: hidden;
}
.box {
display: flex;
justify-content: center;
align-items: center;
position: relative;
width: 580px;
height: 420px;
}
.square-01 {
position: absolute;
top: 0;
right: 0;
z-index: 1;
width: 160px;
height: 160px;
background-color: #ffc900;
}
.square-02 {
position: absolute;
bottom: 0;
left: 0;
z-index: 1;
width: 160px;
height: 160px;
background-color: #fe8500;
}
.card {
position: relative;
z-index: 10;
width: 400px;
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(5px);
backdrop-filter: blur(5px);
}
h1 {
margin: 0;
color: #fff;
font-size: 3rem;
line-height: 1.2;
letter-spacing: 5px;
text-align: center;
}
@media screen and (max-width: 480px) {
.box {
width: 100%;
height: 100vh;
}
.square-01,
.square-02 {
width: 25%;
height: 45%;
}
.card {
width: 85%;
}
h1 {
font-size: 2rem;
}
}