注册页面 HTML 和 CSS 代码示例, 包含基本样式和功能
HTML 代码示例
以下是实现注册页面的 HTML 代码,从表单结构到各个输入域的设置都有所涵盖:
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="styles.css"> <title>注册页面</title> </head> <body> <div class="container"> <h2>用户注册</h2> <form action="#" method="post"> <div class="form-group"> <label for="username">用户名</label> <input type="text" id="username" name="username" required> </div> <div class="form-group"> <label for="email">电子邮件</label> <input type="email" id="email" name="email" required> </div> <div class="form-group"> <label for="password">密码</label> <input type="password" id="password" name="password" required> </div> <button type="submit">注册</button> </form> </div> </body> </html>
CSS 代码示例
为了让注册页面具有良好的外观,我们需要添加一些 CSS 样式。以下是相应的样式代码:
/ styles.css / body { font-family: Arial, sans-serif; background-color: #f4f4f4; margin: 0; padding: 0; } .container { width: 300px; margin: 100px auto; padding: 20px; background: white; border-radius: 5px; box-shadow: 0 0 10px rgba在本示例中,我们创建了一个包含用户输入的注册表单,并应用了一些基本样式,使其既美观又实用。您可以根据需要调整样式,以适应特定的设计需求。
(
0,
0,
0, 0.1); } h2 { text-align: center; } .form-group { margin-bottom: 15px; } label { display: block; margin-bottom: 5px; } input[type="text"], input[type="email"], input[type="password"] { width: 100%; padding: 8px; box-sizing: border-box; border: 1px solid #ddd; border-radius: 4px; } button { width: 100%; padding: 10px; background: #5cb85c; border: none; color: white; border-radius: 5px; cursor: pointer; } button:hover { background: #4cae4c; }