这是一个简单的登录注册页面的HTML和CSS代码示例。请注意,这只是一个基本的示例,不包含任何后端逻辑或表单验证。在实际应用中,你需要添加适当的后端逻辑和安全性措施。
HTML部分:
<!DOCTYPE html> <html> <head> <title>登录注册页面</title> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="container"> <h2>登录</h2> <form action="/login" method="post"> <div class="input-group"> <label for="username">用户名:</label><br> <input type="text" id="username" name="username" required><br> </div> <div class="input-group"> <label for="password">密码:</label><br> <input type="password" id="password" name="password" required><br> </div> <input type="submit" value="登录"> </form> <h2>注册</h2> <form action="/register" method="post"> <!-- 注册表单内容类似登录表单,根据需要添加更多字段 --> <div class="input-group"> <label for="newUsername">用户名:</label><br> <input type="text" id="newUsername" name="newUsername" required><br> </div> <div class="input-group"> <label for="newPassword">密码:</label><br> <input type="password" id="newPassword" name="newPassword" required><br> </div> <!-- 可以添加更多字段如邮箱,手机号等 --> <input type="submit" value="注册"> </form> </div> </body> </html>
CSS部分(styles.css):
body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f0f0f0; } .container { width: 300px; padding: 16px; background-color: white; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); } h2 { text-align: center; } .input-group { margin-bottom: 1em; } label { display: block; margin-bottom: 5px; }
这个简单的登录注册页面使用了基本的HTML表单元素和CSS样式来美化页面,在实际应用中,你可能需要添加更多的功能,比如表单验证、错误处理、用户反馈等,为了安全起见,所有的用户输入都应该经过适当的验证和清理,防止SQL注入等安全问题。