File tree Expand file tree Collapse file tree 3 files changed +98
-0
lines changed Expand file tree Collapse file tree 3 files changed +98
-0
lines changed Original file line number Diff line number Diff line change 1+ const input = document . querySelector ( "input" ) ;
2+ const eye = document . querySelector ( "#eye-icon" ) ;
3+
4+ eye . addEventListener ( "click" , ( ) => {
5+ // if (input.type === "password") {
6+ // input.type = "text";
7+ // } else {
8+ // input.type = "password";
9+ // }
10+
11+ // REFACTOR
12+ input . type === "password" ? ( input . type = "text" ) : ( input . type = "password" ) ;
13+ } ) ;
Original file line number Diff line number Diff line change 1+ < html lang ="en ">
2+ < head >
3+ < meta charset ="UTF-8 " />
4+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Show Hide Password</ title >
7+ < link
8+ rel ="stylesheet "
9+ href ="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css "
10+ integrity ="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g== "
11+ crossorigin ="anonymous "
12+ referrerpolicy ="no-referrer "
13+ />
14+ < link rel ="stylesheet " href ="style.css " />
15+ </ head >
16+ < body >
17+ < div class ="container ">
18+ < input type ="password " placeholder ="Password " />
19+ < div class ="eye-container ">
20+ < i class ="fa fa-eye " aria-hidden ="true " id ="eye-icon "> </ i >
21+ </ div >
22+ </ div >
23+
24+ < script src ="app.js "> </ script >
25+ </ body >
26+ </ html >
Original file line number Diff line number Diff line change 1+ * {
2+ margin : 0 ;
3+ padding : 0 ;
4+ box-sizing : border-box;
5+ font-family : sans-serif;
6+ }
7+
8+ body {
9+ position : relative;
10+ min-height : 100vh ;
11+ background-color : rgb (10 , 10 , 165 );
12+ display : flex;
13+ justify-content : center;
14+ align-items : center;
15+ }
16+
17+ .container {
18+ position : relative;
19+ width : 100% ;
20+ max-width : 400px ;
21+ background : # fff ;
22+ border-radius : 5px ;
23+ padding : 10px ;
24+ display : flex;
25+ justify-content : space-between;
26+ box-shadow : 0 10px 40px rgba (0 , 0 , 0 , 0.05 );
27+ }
28+
29+ input {
30+ outline : none;
31+ background : none;
32+ border : none;
33+ width : 90% ;
34+ padding : 10px 20px ;
35+ font-size : 16px ;
36+ }
37+
38+ .eye-container {
39+ position : absolute;
40+ top : 50% ;
41+ right : 15px ;
42+ transform : translateY (-50% );
43+ width : 40px ;
44+ height : 40px ;
45+ display : flex;
46+ justify-content : center;
47+ align-items : center;
48+ }
49+
50+ # eye-icon {
51+ font-size : 20px ;
52+ color : # 777 ;
53+ transition : 0.2s ease;
54+ }
55+
56+ # eye-icon : hover {
57+ color : rgb (10 , 10 , 165 );
58+ cursor : pointer;
59+ }
You can’t perform that action at this time.
0 commit comments