HTML密码小眼睛

html 复制代码
<!DOCTYPE html>
<html lang="zh_cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>密码小眼睛</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f8f8f8;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .login-container {
            width: 400px;
			height: 300px;
            padding: 40px;
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }
        .login-container h2 {
		    text-align: center;
            margin-bottom: 20px;
        }
        .form-group {
		    text-align: center;
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
        }
        .form-group input[type="text"],
        .form-group input[type="password"] {
            width: 80%;
            padding: 6px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box; /* Makes sure the padding does not affect the total width of the input */
        }
        .form-group input[type="submit"] {   
            width: 80%;
            padding: 8px;
            border: none;
            border-radius: 4px;
            background-color: #5cb85c;
            color: white;
            cursor: pointer;
        }
        .form-group input[type="submit"]:hover {
            background-color: #4cae4c;
        }
    </style>
</head>
<body>
    <div class="login-container" >
        <form action="/" method="GET">
            <div class="form-group">
                <input type="text" id="username" name="username" required placeholder="用户名">
            </div>
            <div class="form-group">
				 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				 <input type="password" id="password" name="password" required placeholder="密码">
				 <span onclick="togglePassword()" id="eyeIcon" class="fa fa-eye"></span>	 
            </div>
            <div class="form-group">
                <input type="submit" value="登录">
            </div>
        </form>
    </div>
</body>
</html>

<script>
function togglePassword() {
  var passwordField = document.getElementById("password");
  var eyeIcon = document.getElementById("eyeIcon");
  if (passwordField.type === "password") {
    passwordField.type = "text";
    eyeIcon.className = "fa fa-eye-slash";
  } else {
    passwordField.type = "password";
    eyeIcon.className = "fa fa-eye";
  }
}
</script>
<!-- 引入Font Awesome图标库 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
相关推荐
yinuo几秒前
Uni-App跨端实战:微信小程序WebView与H5通信全流程解析(01)
前端
xkroy18 分钟前
ajax
前端·javascript·ajax
Yvonne爱编码22 分钟前
AJAX入门-URL、参数查询、案例查询
前端·javascript·ajax
闲人编程31 分钟前
前端形态与样式风格:从古典到现代的视觉语言演进
前端·css·状态模式·组件·js·风格·响应式
JudithHuang32 分钟前
Mac版微信开发者工具登录二维码不显示问题解决方案
前端
Swift社区1 小时前
如何解决 Vue2 前端项目为何无法访问本地资源(chunk.js 加载一直 pending/转圈)
开发语言·前端·javascript
清风细雨_林木木1 小时前
Vue加载资源‘如图片’的“直接引入“方式和“request()“的区别
前端·javascript·vue.js
大熊猫侯佩1 小时前
iOS 26 仅需几行代码让 SwiftUI 7 液态玻璃界面焕发新春
前端·swiftui·apple
BillKu2 小时前
Vue3应用执行流程详解
前端·javascript·vue.js