用gpt写的登录页面

html 复制代码
<!DOCTYPE html>
<html>

<head>
  <title>登录页面</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f4f4f4;
      margin: 0;
      padding: 0;
    }

    .container {
      max-width: 400px;
      margin: 0 auto;
      padding: 20px;
      background-color: #fff;
      border-radius: 5px;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
      margin-top: 100px;
    }

    h1 {
      text-align: center;
    }

    .form-group {
      margin-bottom: 20px;
    }

    label {
      display: block;
      margin-bottom: 5px;
    }

    input[type="text"],
    input[type="password"] {
      width: 100%;
      padding: 10px;
      border: 1px solid #ccc;
      border-radius: 4px;
    }

    button {
      display: block;
      width: 100%;
      padding: 10px;
      background-color: #4caf50;
      color: #fff;
      border: none;
      border-radius: 4px;
      cursor: pointer;
    }

    button:hover {
      background-color: #45a049;
    }
  </style>
</head>

<body>
  <div class="container">
    <h1>登录</h1>
    <form id="loginForm">
      <div class="form-group">
        <label for="username">用户名:</label>
        <input type="text" id="username" placeholder="请输入用户名">
      </div>
      <div class="form-group">
        <label for="password">密码:</label>
        <input type="password" id="password" placeholder="请输入密码">
      </div>
      <button type="submit">登录</button>
    </form>
    <div style="text-align: center; margin-top: 20px;">
      <span>还没有账号?</span>
      <button id="registerButton">注册</button>
    </div>
  </div>

  <script>
    // 获取表单和输入字段的引用
    const form = document.getElementById("loginForm");
    const usernameInput = document.getElementById("username");
    const passwordInput = document.getElementById("password");
    const registerButton = document.getElementById("registerButton");

    // 表单提交事件处理程序
    form.addEventListener("submit", function (event) {
      event.preventDefault(); // 阻止表单默认提交行为

      // 获取输入字段的值
      const username = usernameInput.value;
      const password = passwordInput.value;

      // 进行验证,这里只是简单示例

      // 登录成功,跳转到首页
      window.location.href = "index.html";

    });

    // 注册按钮点击事件处理程序
    registerButton.addEventListener("click", function(event) {
      window.location.href = "register.html";
    });
  </script>
</body>

</html>
相关推荐
z***396211 分钟前
Plugin ‘org.springframework.bootspring-boot-maven-plugin‘ not found(已解决)
java·前端·maven
e***582312 分钟前
Nginx 配置前端后端服务
运维·前端·nginx
小奶包他干奶奶18 分钟前
Webpack学习——Plugin(插件)
前端·学习·webpack
张拭心21 分钟前
AI 从业者需要铭记的时刻:2023年6月30日
前端·ai编程
我叫张小白。33 分钟前
Vue3 Hooks:逻辑复用的解决方案
前端·javascript·vue.js·前端框架·vue
S***t71437 分钟前
前端物联网开发
前端·物联网
IT·小灰灰41 分钟前
深度解析重排序AI模型:基于硅基流动API调用多语言重排序AI实战指南
java·大数据·javascript·人工智能·python·数据挖掘·php
我叫张小白。44 分钟前
Vue3 Props 的使用:组件间数据传递的桥梁
前端·javascript·vue.js·vue3
r***86981 小时前
Nginx解决前端跨域问题
运维·前端·nginx
广州华水科技1 小时前
单北斗GNSS在桥梁变形监测中的关键应用与技术优势分析
前端