HTML代码。
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <title>注册登录页面</title> <style> body { font-family: ’Arial’, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f5f5f5; } .container { width: 300px; padding: 20px; background-color: #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } input[type="text"], input[type="password"] { width: 100%; padding: 15px; margin-bottom: 10px; border-radius: 5px; border: 1px solid #ccc; } input[type="submit"] { width: 100%; padding: 15px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; } </style> </head> <body> <div class="container"> <h2>注册登录</h2> <!-- 注册表单 --> <form id="registerForm"> <input type="text" placeholder="用户名" name="username" required> <input type="password" placeholder="密码" name="password" required> <input type="submit" value="注册"> </form> <!-- 登录表单 --> <form id="loginForm"> <input type="text" placeholder="用户名或邮箱" name="usernameOrEmail"> <input type="password" placeholder="密码" name="password"> <input type="submit" value="登录"> </form> </div> </body> </html>
在这个模板中,我们创建了一个简单的注册和登录表单,用户可以在表单中输入他们的用户名和密码进行注册或登录,在实际应用中,你需要添加适当的后端逻辑来处理这些表单提交,并使用前端验证来确保用户输入的数据是有效的,为了提高用户体验和安全性,你可能还需要添加一些其他功能,如忘记密码、记住我、验证码等。