June 28, 25
Glassmorphism is a modern UI design trend that creates a frosted glass effect for interface elements. It's characterized by background blur, transparency, and subtle borders.
background: rgba(255, 255, 255, 0.2)
- Semi-transparent white backgroundbackdrop-filter: blur(10px)
- Creates the frosted glass effectborder: 1px solid rgba(255, 255, 255, 0.3)
- Subtle light borderbox-shadow
- Adds depth to the elementHere's the CSS that powers the glassmorphism effect:
/* Background with gradient for better effect visibility */
.glass-container {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(45deg, #ff9a9e, #fad0c4, #fad0c4, #a1c4fd);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
padding: 20px;
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
/* Glass card */
.glass-card {
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-radius: 20px;
border: 1px solid rgba(255, 255, 255, 0.3);
padding: 40px;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
width: 300px;
text-align: center;
}
/* Glass button */
.glass-button {
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.3);
padding: 10px 20px;
color: white;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
}
.glass-button:hover {
background: rgba(255, 255, 255, 0.3);
box-shadow: 0 8px 16px 0 rgba(31, 38, 135, 0.2);
}
The key property for glassmorphism is backdrop-filter
, which has the following browser support: