Skip to content

Commit 685e80d

Browse files
committed
add password strength background
1 parent bb1c1d6 commit 685e80d

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

Diff for: 39-password strength background/index.html

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link
7+
rel="stylesheet"
8+
href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/1.8.11/tailwind.min.css"
9+
integrity="sha512-KO1h5ynYuqsFuEicc7DmOQc+S9m2xiCKYlC3zcZCSEw0RGDsxcMnppRaMZnb0DdzTDPaW22ID/gAGCZ9i+RT/w=="
10+
crossorigin="anonymous"
11+
/>
12+
<link rel="stylesheet" href="style.css" />
13+
<title>Password Strength Background</title>
14+
</head>
15+
<body>
16+
<div class="background" id="background"></div>
17+
<div class="bg-white rounded p-10 text-center shadow-md">
18+
<h1 class="text-3xl">Image Password Strength</h1>
19+
<p class="text-sm text-gray-700">Change the password to see the effect</p>
20+
<div class="my-4 text-left">
21+
<label for="email" class="text-gray-900">Email:</label>
22+
<input
23+
type="text"
24+
name="email"
25+
id="email"
26+
class="border block w-full p-2 mt-2 rounded"
27+
placeholder="Enter Email"
28+
/>
29+
</div>
30+
<div class="my-4 text-left">
31+
<label for="password" class="text-gray-900">Password:</label>
32+
<input
33+
type="password"
34+
name="password"
35+
id="password"
36+
class="border block w-full p-2 mt-2 rounded"
37+
placeholder="Enter Password"
38+
/>
39+
</div>
40+
<button
41+
type="submit"
42+
class="bg-black text-white py-2 mt-4 inline-block w-full rounded"
43+
>
44+
Submit
45+
</button>
46+
</div>
47+
<script src="script.js"></script>
48+
</body>
49+
</html>

Diff for: 39-password strength background/script.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const password = document.getElementById("password");
2+
const background = document.getElementById("background");
3+
4+
password.addEventListener("input", (e) => {
5+
const input = e.target.value;
6+
const length = input.length;
7+
const blurValue = 20 - length * 2;
8+
background.style.filter = `blur(${blurValue}px)`;
9+
});

Diff for: 39-password strength background/style.css

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
body {
6+
display: flex;
7+
flex-direction: column;
8+
align-items: center;
9+
justify-content: center;
10+
height: 100vh;
11+
overflow: hidden;
12+
margin: 0;
13+
}
14+
15+
.background {
16+
background: url("https://images.unsplash.com/photo-1556745757-8d76bdb6984b")
17+
no-repeat center center/cover;
18+
position: absolute;
19+
top: -20px;
20+
bottom: -20px;
21+
left: -20px;
22+
right: -20px;
23+
z-index: -1;
24+
filter: blur(20px);
25+
}

0 commit comments

Comments
 (0)