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">
相关推荐
LinXunFeng2 分钟前
Flutter 拖拉对比组件,换装图片前后对比必备
前端·flutter·开源
BD_Marathon3 分钟前
【PySpark】安装测试
前端·javascript·ajax
stu_kk11 分钟前
Ecology9明细表中添加操作按钮与弹窗功能技术分享
前端·oa
带着梦想扬帆启航13 分钟前
UniApp 全局使用字体教程
css·uni-app
dkgee13 分钟前
如何禁止Chrome的重新启动即可更新窗口弹窗提示
前端·chrome
天若有情67335 分钟前
新闻通稿 | 软件产业迈入“智能重构”新纪元:自主进化、人机共生与责任挑战并存
服务器·前端·后端·重构·开发·资讯·新闻
香香爱编程41 分钟前
electron对于图片/视频无法加载的问题
前端·javascript·vue.js·chrome·vscode·electron·npm
程序猿_极客1 小时前
【期末网页设计作业】HTML+CSS+JavaScript 蜡笔小新 动漫主题网站设计与实现(附源码)
前端·javascript·css·html·课程设计·期末网页设计
zl_vslam1 小时前
SLAM中的非线性优-3D图优化之轴角在Opencv-PNP中的应用(一)
前端·人工智能·算法·计算机视觉·slam se2 非线性优化
CDwenhuohuo2 小时前
用spark-md5实现切片上传前端起node模拟上传文件大小,消耗时间
前端