-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
85 lines (77 loc) · 1.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
top: 50%;
left: 50%;
position: absolute;
transform: translate(-50%, -50%);
background: #111;
}
.wrapper {
position: relative;
height: 55px;
width: 320px;
}
input {
width: 100%;
height: 100%;
border: none;
padding-left: 15px;
font-size: 18px;
outline: none;
border-radius: 15px;
background: #fff;
color: #111;
}
input::placeholder {
font-size: 17px;
color: #111;
opacity: 0.8;
}
span {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
font-size: 20px;
color: #111;
cursor: pointer;
display: none;
}
input:valid~span {
display: block;
}
span i.hide-btn::before {
content: "\f070";
}
</style>
<script src="https://kit.fontawesome.com/dd8c49730d.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="wrapper">
<input type="password" placeholder="Enter Password" required>
<span class="show-btn">
<i class="far fa-eye"></i>
</span>
</div>
<script>
const password = document.querySelector("input");
const showpassword = document.querySelector("span i");
showpassword.onclick = (() => {
if (password.type === "password") {
password.type = "text";
showpassword.classList.add("hide-btn");
} else {
password.type = "password";
showpassword.classList.remove("hide-btn");
}
});
</script>
</body>
</html>