How we can create a show and hide password input with an animation effect? Solution: See this Push To Hide Password Input Using jQuery CSS, Show/Hide Password.
Previously I have shared Show Hide Password Input, but this is with a push and ripple animation effect. Basically, when we put a password on fields like login and signup form, then there is a button for show password characters. By default, HTML password input doesn’t show characters but we can see after converting the input to text. This program is all about the switch between password and text input with animation effects.
Today you will learn to create the Show/Hide Password program with ripple click effect. Basically, there is a password field with an SVG eye icon and at first, you can see the password’s characters because it is text input. When you will click on the eye icon, the whole field will push in the icon direction and the password will hide. And on another click it will visible, when you will click on the icon you will see a push effect and a ripple effect.
So, Today I am sharing Push To Hide Password Input Using jQuery CSS. There I have used CSS for styling and jQuery for functioning. And as we know jQuery is a JS library that’s why I am putting this JavaScript category. The eye icon is not based on any library or any PNG image, this is an SVGÂ shape.
If you are thinking now how this push to hide password program actually is, then see the preview given below.
Preview Of Show Pass With Ripple Effect Click
See this video preview to getting an idea of how this program looks like.
Now you can see this visually, also you can see it live by pressing the button given above. If you like this, then get the source code of its.
You May Also Like:
Push To Hide Password Input Using jQuery CSS Source Code
Before sharing source code, let’s talk about it. First I have created a main div named container, and placed two divs, one input and one label inside it. The first div for creating the ripple effect on click and the second div for creating toggle effect, also placed an SVG icon inside the second div. I have created a text input with ID name, placeholder, and label, later it will change to password input on click.
Now using CSS I have placed all the elements in the right place, as you can see in the preview. With CSS I gave size, position, margin, padding, etc values to the elements. For creating the ripple effect I have used flex display, transition command, and CSS @keyframe animation. There I have used transform command many times.
jQuery handling here the toggle feature and show animations of this program. First, fetched all the elements using document.querySelector() command and stored in variables. Later it changing the input type between text and password according to action, also it adding and removing CSS class names.
Left all other things you will understand after getting the codes, I can’t explain all in writing. For creating this program you have to create 3 files. First file for HTML, second for CSS, and the third file for JavaScript. Follow the steps to creating this without any error.
index.html
Create an HTML file named ‘index.html‘ and put these codes given here.
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 |
<!DOCTYPE html> <!-- Code By Webdevtrick ( https://webdevtrick.com ) --> <html lang="en" > <head> <meta charset="UTF-8"> <title>Push to Hide Password | Webdevtrick.com</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Poppins'> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <div class="ripple"></div> <div class="toggle" data-state="visible"> <svg xmlns="http://www.w3.org/2000/svg" class="eye" width="32" height="32"><circle cx="16" cy="15" r="3"/><path d="M30 16s-6.268 7-14 7-14-7-14-7 6.268-7 14-7 14 7 14 7zM22.772 10.739a8 8 0 1 1-13.66.189"/></svg> </div> <input type="text" id="password" placeholder="Enter password" autocomplete="off"> <label for="password"></label> </div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script> <script src="function.js"></script> </body> </html> |
style.css
Now create a CSS file named ‘style.css‘ and put these codes given here.
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
/* Code By Webdevtrick ( https://webdevtrick.com ) */ html, body { margin: 0; padding: 0; } body, input { display: flex; justify-content: center; align-items: center; } *, *:before, *:after { box-sizing: border-box; } html, body { width: 100%; height: 100%; font-family: "Poppins", sans-serif; } body { width: 100%; height: 100%; overflow: hidden; background: #ff6d6d; } .container { position: relative; -webkit-perspective: 80; perspective: 80; border-radius: 100vw; } .ripple { position: absolute; width: 180px; height: 70px; z-index: 90; right: 0; transition: -webkit-transform 0.2s; transition: transform 0.2s; transition: transform 0.2s, -webkit-transform 0.2s; transition: transform 0.2s; display: flex; justify-content: flex-end; align-items: center; padding: 0 25px; overflow: hidden; border-radius: 100vw; pointer-events: none; } .ripple.animate:before { -webkit-animation: clicked 0.4s forwards cubic-bezier(0.5, 0.61, 0.36, 1); animation: clicked 0.4s forwards cubic-bezier(0.5, 0.61, 0.36, 1); } .ripple:before { content: ""; background: rgba(0, 0, 0, 0.1); width: 100px; height: 100px; position: absolute; top: 50%; right: 41px; border-radius: 50%; opacity: 0; -webkit-transform: translate(50%, -50%) scale(0.5); transform: translate(50%, -50%) scale(0.5); pointer-events: none; } @-webkit-keyframes clicked { 0% { opacity: 0; -webkit-transform: translate(50%, -50%) scale(0.5); transform: translate(50%, -50%) scale(0.5); } 10% { opacity: 0.8; } 100% { opacity: 0; -webkit-transform: translate(50%, -50%) scale(1.2); transform: translate(50%, -50%) scale(1.2); } } @keyframes clicked { 0% { opacity: 0; -webkit-transform: translate(50%, -50%) scale(0.5); transform: translate(50%, -50%) scale(0.5); } 10% { opacity: 0.8; } 100% { opacity: 0; -webkit-transform: translate(50%, -50%) scale(1.2); transform: translate(50%, -50%) scale(1.2); } } .toggle { position: absolute; width: 85px; height: 70px; background: transparent; z-index: 100; right: 0; top: 0; transition: -webkit-transform 0.2s; transition: transform 0.2s; transition: transform 0.2s, -webkit-transform 0.2s; display: flex; justify-content: center; align-items: center; padding: 0; overflow: hidden; border-radius: 100vw; cursor: pointer; } .toggle:before { content: ""; display: block; position: absolute; left: 35px; top: 25px; height: 2px; background: black; -webkit-transform-origin: top left; transform-origin: top left; -webkit-transform: rotateZ(46deg); transform: rotateZ(46deg); transition: width 0.13s ease-out; } .toggle[data-state="visible"]:before { width: 25px; } .toggle[data-state="hidden"]:before { width: 0; } .toggle .eye { fill: #000000; transition: -webkit-transform .13s linear; transition: transform .13s linear; transition: transform .13s linear, -webkit-transform .13s linear; stroke-width: 0; -webkit-transform: scale(1) rotateY(0); transform: scale(1) rotateY(0); } .toggle .eye path { fill: none; stroke-width: 1.5; stroke-miterlimit: 5; stroke: #000000; } .toggle:active { -webkit-transform: scale(0.9); transform: scale(0.9); } .toggle:active + input { -webkit-transform: rotateY(1deg); transform: rotateY(1deg); letter-spacing: 1.5px; box-shadow: 3px 0px 15px 0px #c1e6d0; cursor: text; } .toggle:active + input.password { letter-spacing: 3px; } .toggle:active:before { -webkit-transform: rotateZ(46deg) rotateY(5deg); transform: rotateZ(46deg) rotateY(5deg); } .toggle:active .eye { -webkit-transform: scale(0.75) rotateY(5deg); transform: scale(0.75) rotateY(5deg); } input { width: 340px; height: 70px; background: #ffffff; border-radius: 10px; will-change: transform; border-radius: 100vw; transition: all 0.2s ease; cursor: pointer; color: #ffffff; font-size: 22px; color: #000000; outline: none; text-align: left; border: 0; padding: 10px 80px 10px 30px; -webkit-transform-origin: left center; transform-origin: left center; transition: -webkit-transform 0.13s; transition: transform 0.13s; transition: transform 0.13s, -webkit-transform 0.13s; font-family: "Poppins", sans-serif; box-shadow: 0px 0px 30px 0px #ff2e2e; transition: letter-spacing 0.13s ease-out, box-shadow 0.13s ease-out; } input::-moz-selection { background: #ff8181; } input::selection { background: #ff8181; } input::-webkit-input-placeholder { color: #ff7474; } input:-ms-input-placeholder { color: #ff7474; } input::-ms-input-placeholder { color: #ff7474; } input::placeholder { color: #ff7474; } input.password { letter-spacing: 1px; } |
function.js
The final step, create a JavaScript file named ‘function.js‘ and put the codes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
// Code By Webdevtrick ( https://webdevtrick.com ) var eye = document.querySelector('.eye'), ripple = document.querySelector('.ripple'), toggle = document.querySelector('.toggle'), input = document.querySelector('input'); function click(e) { // Ripple Effect ripple.classList.add('animate'); // Push Effect input.classList.add('animate'); // Toggle input type between: password / text input.classList.toggle('password'); input.type === 'text' ? input.type = 'password' : input.type = 'text'; toggle.dataset.state = input.type === 'text' ? 'visible' : 'hidden'; } toggle.addEventListener('click', click); // Remove all after animation ends function removeAnimate() { ripple.classList.remove('animate'); input.classList.remove('animate'); toggle.style.pointerEvents = 'all'; } ripple.addEventListener('animationend', removeAnimate); |
That’s It. Now you have successfully created Push To Hide Password Input Using jQuery CSS, Show/Hide Password. If you have any doubt or question comment down below.
Thanks For Visiting, Keep Visiting.