Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Create A Glassmorphism Login Form in HTML and CSS
This article will show you how to design a glassmorphism login form using HTML and CSS. Glassmorphism is a popular UI design trend based on frosted glass effects, which make elements look translucent with a blurred background.
What is Glassmorphism?
Glassmorphism is a UI design style that gives an element a frosted-glass effect with the following characteristics
- Blurred Background: Creates a glassy, frosted effect.
- Transparency: Allows part of the background to show through.
- Light Borders and Shadows: Adds depth and defines the shape.
Key CSS Properties for Glassmorphism
.glass-effect {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(15px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 15px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
Creating the HTML Structure
We start by building the structure of the login form. The container holds the username and password input fields along with a submit button
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Glassmorphism Login Form</title>
</head>
<body>
<div class="glass-container">
<h2>Login</h2>
<form>
<input type="text" class="input-field" placeholder="Username" required>
<input type="password" class="input-field" placeholder="Password" required>
<button type="submit" class="btn">Login</button>
</form>
</div>
</body>
</html>
Complete Glassmorphism Login Form
Here's the complete implementation with all the glassmorphism styling
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Glassmorphism Login Form</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(135deg, #ff8a00, #da1b60);
overflow: hidden;
}
body::before {
content: '';
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
background: linear-gradient(135deg, #ff8a00, #da1b60, #fcb045, #e91e63);
background-size: 400% 400%;
z-index: -2;
animation: gradient-animation 8s ease infinite;
}
@keyframes gradient-animation {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.glass-container {
position: relative;
width: 350px;
padding: 40px;
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
backdrop-filter: blur(15px);
-webkit-backdrop-filter: blur(15px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.glass-container h2 {
text-align: center;
color: #fff;
margin-bottom: 20px;
font-size: 1.8em;
}
.input-field {
width: 100%;
padding: 12px 10px;
margin: 15px 0;
border: none;
outline: none;
background: rgba(255, 255, 255, 0.15);
color: #fff;
font-size: 1em;
border-radius: 5px;
transition: 0.4s ease;
}
.input-field:focus {
background: rgba(255, 255, 255, 0.3);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
transform: scale(1.02);
}
.btn {
width: 100%;
padding: 12px;
margin-top: 20px;
background: linear-gradient(135deg, #ff8a00, #da1b60);
border: none;
border-radius: 5px;
color: #fff;
font-size: 1em;
cursor: pointer;
transition: all 0.4s ease;
text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
}
.btn:hover {
background: linear-gradient(135deg, #e91e63, #ff8a00);
box-shadow: 0 0 15px rgba(255, 138, 0, 0.6), 0 0 15px rgba(234, 30, 99, 0.6);
transform: scale(1.05);
}
::placeholder {
color: rgba(255, 255, 255, 0.7);
opacity: 0.9;
}
</style>
</head>
<body>
<div class="glass-container">
<h2>Login</h2>
<form>
<input type="text" class="input-field" placeholder="Username" required>
<input type="password" class="input-field" placeholder="Password" required>
<button type="submit" class="btn">Login</button>
</form>
</div>
</body>
</html>
A translucent glass-effect login form appears centered on an animated gradient background. The form has white semi-transparent input fields and a gradient submit button with hover effects.
Key CSS Properties Explained
| Property | Purpose |
|---|---|
backdrop-filter: blur(15px) |
Creates the frosted glass blur effect |
background: rgba(255, 255, 255, 0.1) |
Semi-transparent white background |
border: 1px solid rgba(255, 255, 255, 0.2) |
Subtle light border for definition |
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) |
Adds depth with shadow |
Conclusion
We successfully created a glassmorphism login form using HTML and CSS. The key elements are the backdrop-filter for the blur effect, semi-transparent backgrounds using RGBA, and subtle borders and shadows for depth.
