js实现输入密码显示或隐藏功能按钮效果代码

代码语言:html

所属分类:表单美化

代码描述:js实现输入密码显示或隐藏功能按钮效果代码

代码标签: 密码 显示 隐藏 功能 按钮 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <style>
        @charset "utf-8";
    :root {
    	--light-grey: #e0e0e0;
    	--dark-grey: #c5c5c5;
    }
    
    body {
    	margin: 0;
    	padding: 0;
    	width: 100%;
    	height: 100vh;
    	display: flex;
    	justify-content: center;
    	align-items: center;
    	background: var(--light-grey);
    	font-family: monospace, Arial, Helvetica, sans-serif;
    }
    
    body * {
    	box-sizing: border-box;
    	outline: none;
    }
    
    .container {
    	width: 210px;
    	position: relative;
    }
    
    input {
    	background: #ececec;
    	border: 0;
    	font-size: 1em;
    	width: 100%;
    	box-shadow: 0.15em 0.15em 0.25em var(--dark-grey) inset,
    		-0.15em -0.15em 0.25em #ffffff80 inset, 0.3em 0.3em 0.6em var(--dark-grey),
    		-0.2em -0.2em 0.5em #ffffff80;
    	border-radius: 4px;
    	padding: 10px;
    	position: absolute;
    	z-index: 1;
    	height: 40px;
    	color: #808080;
    	font-family: monospace, Arial, Helvetica, sans-serif;
    }
    
    input::placeholder {
    	color: #808080;
    	opacity: 1;
    }
    
    input:-ms-input-placeholder {
    	color: #808080;
    }
    
    input::-ms-input-placeholder {
    	color: #808080;
    }
    
    input.active {
    	animation: scanning 1s ease 0s 1;
    	background: linear-gradient(90deg, #02de0b 50%, #ececec 100%);
    	background-repeat: no-repeat;
    	background-position: -210px;
    	background-color: #ececec;
    }
    
    @keyframes scanning {
    	0% {
    		background-position: 150px;
    	}
    	100% {
    		background-position: -210px;
    	}
    }
    
    #reveal {
    	width: 40px;
    	height: 40px;
    	border-radius: 4px;
    	border: 0;
    	background: linear-gradient(145deg, #72c0ff, #0070ca);
    	cursor: pointer;
    	position: absolute;
    	z-index: 3;
    	right: 0px;
    	box-shadow: 0.3em 0.3em 0.6em var(--dark-grey), -0.2em -0.2em 0.5em #fff;
    	border: 2px solid var(--light-grey);
    	transition: all 0.5s ease 0s;
    	border-top-color: #cccccc;
    	border-bottom-color: #eee;
    }
    
    #reveal:before {
    	content: "";
    	background: radial-gradient(
    		circle at center,
    		#00000080 1px,
    		#00000080 2px,
    		#00000080 3px,
    		#00000080 4px
    	);
    	width: 18px;
    	height: 18px;
    	border-radius: 0 100%;
    	transform: rotate(-45deg) skew(-10deg, -10deg);
    	left: 9px;
    	position: absolute;
    	top: 9px;
    	transition: all 0.25s ease 0s;
    }
    
    #reveal:after {
    	content: "";
    	width: 20px;
    	height: 18px;
    	border-radius: 100%;
    	left: 6px;
    	top: 4px;
    	position: absolute;
    	border: 2px dotted #fff0;
    	border-bottom-color: #00000080;
    	transition: all 0.25s ease 0s;
    }
    
    #reveal:disabled {
    	transition: all 0.5s ease 0s;
    	background: linear-gradient(145deg, #ced5e0, #757575) !important;
    	cursor: default;
    }
    
    #reveal.open {
    	transition: all 0.5s ease 0s;
    	background: linear-gradient(145deg, #8ce88f, #009205);
    }
    
    #reveal.open:after {
    	transform: rotateX(-180deg);
    	top: 10px;
    	background: radial-gradient(
    		circle at 50% 12px,
    		#00000000 1px,
    		#ececec 2px,
    		#ffffff 3px,
    		#00000000 4px
    	);
    }
    
    #reveal span:before {
    	display: none;
    	font-family: monospace;
    }
    
    #reveal:hover span:before {
    	content: "显示密码";
    	display: block;
    	position: absolute;
    	background: #4fa8ef;
    	top: -4.5em;
    	padding: 0.45em 0.5em;
    	left: -0.9em;
    	border-radius: 2px;
    	font-size: 0.85em;
    	color: #1d4c72;
    	min-width: 4.25em;
    	min-height: 2.25em;
    	line-height:2.25em;
    }
    
    #reveal:hover span:after {
    	content: "";
    	display: block;
    	position: absolute;
    	border: 0.7em solid transparent;
    	border-top-color: #4fa.........完整代码请登录后点击上方下载按钮下载查看

网友评论0