-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" | ||
integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" | ||
crossorigin="anonymous" | ||
/> | ||
<title>Show Hide Password</title> | ||
<link rel="stylesheet" href="./style.css" /> | ||
</head> | ||
<body> | ||
<div class="inputBox"> | ||
<input id="password" type="password" placeholder="Enter your password" /> | ||
<div id="toggle"> | ||
<i | ||
id="icon" | ||
class="fas fa-eye-slash fa-2x" | ||
onclick="showHide();" | ||
style="padding: 5px" | ||
></i> | ||
</div> | ||
</div> | ||
|
||
<script src="./script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const password = document.getElementById("password"); | ||
const toggle = document.getElementById("toggle"); | ||
const icon = document.getElementById("icon"); | ||
function showHide() { | ||
if (password.type === "password") { | ||
password.setAttribute("type", "text"); | ||
toggle.classList.remove("hide"); | ||
icon.classList.remove("fa-eye-slash"); | ||
icon.classList.add("fa-eye"); | ||
} else { | ||
password.setAttribute("type", "password"); | ||
toggle.classList.add("hide"); | ||
icon.classList.add("fa-eye-slash"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
min-height: 100vh; | ||
background: #f8f8f8; | ||
} | ||
.inputBox { | ||
position: relative; | ||
width: 400px; | ||
height: 60px; | ||
} | ||
.inputBox input { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
font-size: 25px; | ||
padding: 15px; | ||
outline: none; | ||
border: none; | ||
border-radius: 8px; | ||
background: transparent; | ||
box-sizing: border-box; | ||
box-shadow: -4px -4px 10px rgba(255, 255, 255, 1), | ||
inset 4px 4px 10px rgba(0, 0, 0, 0.05), | ||
inset -4px -4px 10px rgba(255, 255, 255, 1), | ||
4px 4px 10px rgba(0, 0, 0, 0.05); | ||
} | ||
.inputBox input::placeholder { | ||
color: rgb(146, 140, 140); | ||
} | ||
#toggle { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
width: 45px; | ||
height: 30px; | ||
background-size: cover; | ||
padding: 5px; | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} |