HTML 登录页面_点击密码框小眼睛可显示输入密码_水平排列元素(高度不同)的底部对齐方式

  • Post author:
  • Post category:其他


登录页面代码:


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>登录页面</title>

   
</head>
<style type="text/css">
    
/* 父容器 */
.box {
    position: relative;
    width: 260px;
    margin: 1px auto;
}
/* 子容器 底部对齐 */
.box .child {
    display: inline-block;
    vertical-align: bottom;
    height:27px;
}

</style>
<body>
    <div class="box">
        <div class="child">
            <img src="user.png" style="height: 27px;width: 27px;"/>
        </div>
        <div class="child">
            <input type="text" id="username" value=""  style="border:none !important; height: 27px; width: 158px;" placeholder="请输入用户名"/>
            
        </div>
        <hr style="background-color: #dedee2;height: 1px;border: none;">
        <div class="child">
            <img src="password.png"  style="height: 25px;width: 25px;"/>
        </div>
        <div class="child">
            <input type="password" id="password" value="" style="border:none !important;height: 27px;" placeholder="请输入密码" />
        </div>
        <div class="child">
            <img src="close.png" alt="" id="eye" class="eye" />
        </div>
        <hr style="background-color: #dedee2;height: 1px;border: none;">

        <br>
        <div align="center">
            <input type="button"  value="登     录" 
            onclick="login()" 
            style="border:none; border-radius: 40px !important; 
            background-color: #2E65FE;color: #ffffff; width: 150px;height: 40px;"/>
        </div>
    </div>
</body>
<script>

    // 1.获取元素
    var eye = document.getElementById('eye');
    var pwd = document.getElementById('password');
    // 2.注册事件 处理程序
    var flag = 0;
    eye.onclick = function() {
        // 点击一次之后,flag一定要变化
        if (flag == 0) {
            pwd.type = 'text';
            eye.src = 'open.png';
            flag = 1; //赋值操作
        } else {
            pwd.type = 'password';
            eye.src = 'close.png';
            flag = 0;
        }
    }

    //登录事件
    function login(){
        var username = document.getElementById('username').value;
        var password = document.getElementById('password').value;

        alert("username:"+username)
        alert("password:"+password)
    }
</script>
</html>

效果:

参考:


点击密码框显示密码(点击密码框小眼睛可显示输入密码)_html密码框添加小眼睛_龙眸的博客-CSDN博客


水平排列元素(高度不同)的底部对齐方式_裂痕中的阳光.ゝ的博客-CSDN博客_不定高度 底部对齐



版权声明:本文为zhuiqiuzhuoyue583原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。