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">
相关推荐
IT_陈寒1 天前
SpringBoot自动配置的坑,我调试到凌晨三点才爬出来
前端·人工智能·后端
qq_339191141 天前
kimi-cli 服务形式启动,kimi-cli无头模式 kimi-cli web启动,
服务器·前端·javascript
落魄江湖行1 天前
入门篇四:Nuxt4布局系统:让页面框架复用变得简单
前端·vue·nuxt4
恋猫de小郭1 天前
你的 AI 不好用,可能只是它在演你,或者在闹情绪
前端·人工智能·ai编程
那我懂你的意思啦1 天前
Vue2+Vue3学习
前端·vue.js·学习
@大迁世界1 天前
17.在 React 中如何根据条件决定渲染哪个组件?
前端·javascript·react.js·前端框架·ecmascript
小则又沐风a1 天前
类和对象----最终篇
java·前端·数据库
travel_wsy1 天前
PLY三维模型在vue中的展示
前端·javascript·vue.js
还是大剑师兰特1 天前
Vite + Vue 3 一体化开发调试插件:vite-plugin-vue-devtools
前端·javascript·vue.js
晓得迷路了1 天前
栗子前端技术周刊第 123 期 - axios 包遭入侵、Babylon.js 9.0、Node.js 25.9.0...
前端·javascript·axios