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">
相关推荐
问心无愧051316 分钟前
ctf show web入门111
android·前端·笔记
唐某人丶25 分钟前
模型越来越强,我们还需要 Agent 工程吗?—— 从价值重估到 Harness 实践
前端·agent·ai编程
智码看视界37 分钟前
现代Web开发基础:全栈工程师的起航点
前端·后端·c5全栈
JS菌1 小时前
手写一个 AI Agent 全栈项目:从沙箱执行到子智能体的完整实现
前端·人工智能·后端
excel2 小时前
HLS TS 文件损坏的元凶:Git 提交与拉取
前端
Aphasia3112 小时前
https连接传输流程
前端·面试
徐小夕2 小时前
万字长文!千万级文档 RAG 知识库系统落地实践
前端·算法·github
threelab2 小时前
Three.js 物理模拟着色器 | 三维可视化 / AI 提示词
开发语言·前端·javascript·人工智能·3d·着色器
kyriewen3 小时前
CSS Container Queries:彻底告别 @media 写到手软,附 5 个真实布局案例
前端·css·面试