Creating a glassmorphic connection form in HTML and CSS
In this article, we will create a form with a glassmorphic design. A modern effect guaranteed!
Step 1
Let's start with the HTML code.
<div class="container">
<form >
<p>Welcome</p>
<input type="email" placeholder="Email"><br>
<input type="password" placeholder="Password"><br>
<input type="button" value="Login"><br>
<a href="#">Forgot Password</a>
</form>
<div class="drop drop-1"></div>
<div class="drop drop-2"></div>
<div class="drop drop-3"></div>
<div class="drop drop-4"></div>
<div class="drop drop-5"></div>
</div>
Step 2
Let's move on to the design of our form page.
body {
background: linear-gradient(45deg, #FC466B, #3F5EFB);
height: 100vh;
font-family: arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
}
.container {
position: relative;
}
So far, we are only centering our form using Flexbox.
The drop classes will allow us to display small transparent clouds around our form.
Step 3
Now it's the form's turn.
form {
background: rgba(255, 255, 255, .3);
padding: 3rem;
height: 320px;
border-radius: 20px;
border-left: 1px solid rgba(255, 255, 255, .3);
border-top: 1px solid rgba(255, 255, 255, .3);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
-moz-backdrop-filter: blur(10px);
box-shadow: 20px 20px 40px -6px rgba(0, 0, 0, .2);
text-align: center;
}
Step 4
Let's now style the texts.
p {
color: white;
font-weight: 500;
opacity: .7;
font-size: 1.4rem;
margin-bottom: 60px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, .2);
}
a {
text-decoration: none;
color: #ddd;
font-size: 12px;
}
a:hover {
text-shadow: 2px 2px 6px #00000040;
}
a:active {
text-shadow: none;
}
Step 5
Let's move on to the inputs.
input {
background: transparent;
border: none;
border-left: 1px solid rgba(255, 255, 255, .3);
border-top: 1px solid rgba(255, 255, 255, .3);
padding: 1rem;
width: 200px;
border-radius: 50px;
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
-moz-backdrop-filter: blur(5px);
box-shadow: 4px 4px 60px rgba(0, 0, 0, .2);
color: white;
font-weight: 500;
text-shadow: 2px 2px 4px rgba(0, 0, 0, .2);
transition: all .3s;
margin-bottom: 2em;
}
Step 6
Let's style the interactions.
input:hover,
input[type="email"]:focus,
input[type="password"]:focus{
background: rgba(255,255,255,0.1);
box-shadow: 4px 4px 60px 8px rgba(0,0,0,0.2);
}
input[type="button"] {
margin-top: 10px;
width: 150px;
font-size: 1rem;
cursor: pointer;
}
::placeholder {
color: #fff;
}
Step 7
Let's handle the shadows.
.drop {
background: rgba(255, 255, 255, .3);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-radius: 10px;
border-left: 1px solid rgba(255, 255, 255, .3);
border-top: 1px solid rgba(255, 255, 255, .3);
box-shadow: 10px 10px 60px -8px rgba(0,0,0,0.2);
position: absolute;
transition: all 0.2s ease;
}
Step 8
Let's finish our form by styling each shadow one by one.
.drop-1 {
height: 80px; width: 80px;
top: -20px; left: -40px;
z-index: -1;
}
.drop-2 {
height: 80px; width: 80px;
bottom: -30px; right: -10px;
}
.drop-3 {
height: 100px; width: 100px;
bottom: 120px; right: -50px;
z-index: -1;
}
.drop-4 {
height: 120px; width: 120px;
top: -60px; right: -60px;
}
.drop-5 {
height: 60px; width: 60px;
bottom: 170px; left: 90px;
z-index: -1;
}