Table of Contents
Creating a modern and visually appealing login page can enhance user experience on your website. In this tutorial, we will guide you through building a glassmorphic login page step-by-step using HTML, CSS, and some simple design principles.
What is a Glassmorphic Design?
Glassmorphism is a popular UI trend characterized by a frosted-glass effect, semi-transparent backgrounds, and subtle shadows. It creates a sleek, modern look that adds depth and sophistication to your pages.
Step 1: Set Up Your HTML Structure
Start with a simple HTML structure for your login form. This includes a container for the form and input fields for username and password.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Glassmorphic Login Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="login-container">
<h2>Login</h2>
<form>
<input type="text" placeholder="Username" required>
<input type="password" placeholder="Password" required>
<button type="submit">Sign In</button>
</form>
</div>
</body>
</html>
Step 2: Apply Glassmorphic CSS Styles
Next, add CSS styles to achieve the glassmorphic effect. Use semi-transparent backgrounds, backdrop filters, and shadows.
/* styles.css */
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #74ebd5, #ACB6E5);
font-family: Arial, sans-serif;
}
.login-container {
background: rgba(255, 255, 255, 0.2);
padding: 40px;
border-radius: 15px;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.18);
width: 300px;
text-align: center;
}
h2 {
margin-bottom: 20px;
color: #fff;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 12px 20px;
margin: 10px 0;
border: none;
border-radius: 10px;
background: rgba(255, 255, 255, 0.3);
color: #fff;
font-size: 16px;
outline: none;
transition: background 0.3s;
}
input[type="text"]:focus,
input[type="password"]:focus {
background: rgba(255, 255, 255, 0.5);
}
button {
width: 100%;
padding: 12px 20px;
margin-top: 15px;
border: none;
border-radius: 10px;
background-color: #ffffff;
color: #333;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #f0f0f0;
}
Step 3: Final Touches
Ensure your CSS file is linked correctly in your HTML. You can customize colors, fonts, and sizes to match your branding. Test the page on different devices to ensure responsiveness and visual appeal.
With these steps, you now have a sleek, glassmorphic login page that enhances your website’s modern look. Feel free to add animations or additional styles to further customize your design.