Pink老师JS学习--京东登录页面案例
作者:互联网
感谢pink老师的课程。
这是我自己写的样式,比较丑。
这个案例是主要是练习巩固操作元素,实现了密码隐藏显示的功能。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.sign {
width: 600px;
margin: 100px auto;
}
h1 {
font-size: 28px;
font-weight: 400;
padding-bottom: 30px;
text-align: center;
color: rgb(245, 100, 100);
}
.box,
.user {
position: relative;
color: rgb(66, 66, 66);
width: 100%;
border-bottom: 1px solid rgb(228, 228, 228);
}
.user input {
width: 100%;
height: 40px;
font-size: 20px;
border: 0;
}
#pwd {
width: 460px;
height: 46px;
font-size: 20px;
border: 0;
}
#eye {
position: absolute;
top: 11px;
right: 80px;
width: 24px;
}
.box label {
position: absolute;
right: 10px;
color: #cdcdcd;
font-size: 14px;
line-height: 46px;
}
.bt {
width: 500px;
height: 32px;
margin-left: 50px;
margin-top: 28px;
border: 0;
border-radius: 16px;
background-color: rgb(255, 60, 0);
color: white;
}
.bt:hover {
outline: none;
}
input:focus {
outline: none;
}
.rem {
position: relative;
}
.rem label,
span {
color: gray;
font-size: 14px;
}
.rem label {
position: absolute;
left: 50px;
top: 10px;
}
.rem span {
position: absolute;
top: 10px;
right: 50px;
}
</style>
</head>
<body>
<div class="sign">
<h1>会员登录</h1>
<!--输入用户名-->
<div class="user">
<input type="text">
</div>
<!--输入密码-->
<div class="box">
<input type="password" id="pwd">
<img src="隐藏.png" alt="" id="eye">
<label for="">| 忘记密码</label>
</div>
<!--登录按钮-->
<button class="bt">登录</button>
<!--信息提示-->
<div class="rem">
<label>短信验证码登录</label>
<span>手机快速注册</span>
</div>
</div>
</body>
<script>
/*获取对象*/
var eye = document.getElementById('eye');
var pwd = document.getElementById('pwd');
//注册事件
var flag = 0;
eye.onclick = function () {
if (flag = 0) { //这里不能用=号,要用==号
pwd.type = 'password';
eye.src = '隐藏.png';
flag = 1;
} else {
pwd.type = 'text';
eye.src = '显示 (1).png';
flag = 0;
}
}
</script>
</html>
标签:Pink,eye,width,--,JS,color,position,font,border 来源: https://blog.csdn.net/YuKing_HONG/article/details/115013475