博客列表 >完成一个用户注册页面(表单实现)

完成一个用户注册页面(表单实现)

南宫
南宫原创
2020年06月22日 16:33:061157浏览

```html
<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>表单实现注册</title>

  1. <style>
  2. body{
  3. color: #555;
  4. }
  5. h3{
  6. text-align: center;
  7. }
  8. form{
  9. width: 450px;
  10. margin: 30px auto;
  11. border-top: 1px solid #aaa;
  12. }
  13. /* fieldset 改变边框样式,加圆角化 */
  14. form fieldset{
  15. border: 1px solid seagreen;
  16. background-color: lightcyan;
  17. box-shadow: 2px 2px 4px #bbb;
  18. border-radius: 10px;
  19. margin: 20px;
  20. }
  21. /* fieldset标题样式 */
  22. form fieldset legend{
  23. background-color: rgb(178, 231, 201);
  24. border-radius: 10px;
  25. color: seagreen;
  26. padding: 5px 15px;
  27. }
  28. form div{
  29. margin: 5px;
  30. }
  31. form p{
  32. text-align: center;
  33. }
  34. form .btn{
  35. width: 80px;
  36. height: 30px;
  37. border: none;
  38. background-color: seagreen;
  39. color: #ddd;
  40. }
  41. form .btn:hover{
  42. background-color: coral;
  43. color: white;
  44. cursor: pointer;
  45. }
  46. input:focus{
  47. background-color: rgb(226, 226, 176);
  48. }
  49. </style>

</head>

<body>
<h3>用户注册</h3>
<form action="" method="POST">

  1. <!-- fieldset 元素可将表单内的相关元素分组。 -->
  2. <fieldset>
  3. <!-- egend 元素为 fieldset 元素定义标题(caption) -->
  4. <legend>基本信息(必填)</legend>
  5. <div>
  6. <lable for="my-username">账号:</lable>
  7. <!-- autofocus 自动获取焦点 -->
  8. <!-- placeholder提示语 -->
  9. <input type="text"
  10. id="my-username"
  11. name="username"
  12. placeholder="6-15位字符"
  13. autofocus/>
  14. </div>
  15. <div>
  16. <label for="email-id">邮箱</label>
  17. <input type="email" name="email" id="email-id" placeholder="demo@example.com"/>
  18. </div>
  19. <!-- 密码 -->
  20. <div>
  21. <label for="pwd-1">密码</label>
  22. <input type="password" name="password1" id="pwd-1" placeholder="不少于6位且字母+数字"/>
  23. </div>
  24. <div>
  25. <label for="pwd-2">确认</label>
  26. <input type="password" name="password2" id="pwd-1">
  27. </div>
  28. </fieldset>
  29. <fieldset>
  30. <legend>扩展信息(选填)</legend>
  31. <div>
  32. <!-- lable 包含 input标签可以增加点击区域-->
  33. <lable>
  34. 生日
  35. <input type="date" name="birthday" id="">
  36. </lable>
  37. </div>
  38. <div>
  39. <!-- 单选按钮 -->
  40. <label for="secret">性别:</label>
  41. <!-- 单选按钮中name属性值必须相同 -->
  42. <input type="radio" name="gender" id="male" value="male"/>
  43. <label for="male"></label>
  44. <input type="radio" name="gender" id="female" value="female">
  45. <label for="female"></label>
  46. <input type="radio" name="gender" id="secret" value="secret" checked>
  47. <label for="secret">保密</label>
  48. </div>
  49. <div>
  50. <!-- 复选框 -->
  51. <label for="programme">爱好</label>
  52. <!-- 因为复选框返回是一个或多个值,最方便后端用数组来处理, 所以将name名称设置为数组形式便于后端脚本处理 -->
  53. <input type="checkbox" name="hobby[]" id="game" value="game"/><label for="game">打游戏</label>
  54. <input type="checkbox" name="hobby[]" id="shoot" value="shoot"/><label for="shoot">摄影</label>
  55. <input type="checkbox" name="hobby[]" id="programme" value="programme" checked/><label for="programme">编程</label>
  56. </div>
  57. <div>
  58. <!-- 选项列表 -->
  59. <label for="brand">手机:</label>
  60. <input type="search" name="brand" id="brand" list="phone"/>
  61. <datalist id="phone">
  62. <option value="apple" label="iPhone"></option>
  63. <option value="huawei" label="华为"></option>
  64. <option value="xiaomi" label="小米"></option>
  65. </datalist>
  66. </div>
  67. </fieldset>
  68. <fieldset>
  69. <legend>其他信息(选填)</legend>
  70. <!-- 文件上传 -->
  71. <div>
  72. <label for="uploads">上传头像</label>
  73. <input type="file" name="user_pic" id="uploads" accept="image/png,image/jpeg,image/gif">
  74. </div>
  75. <!-- 文本域 -->
  76. <div>
  77. <label for="resume">简历:</label>
  78. <!-- 注意文本域没有value属性 -->
  79. <textarea name="resume" id="resume" cols="30" rows="5" placeholder="不超过100字"></textarea>
  80. </div>
  81. </fieldset>
  82. <!-- 隐藏域,例如用户的Id,注册,登录的时间 -->
  83. <input type="hidden" name="user_id" value="123"/>
  84. <p>
  85. <input type="submit" value="提交" class="btn"/>
  86. </p>
  87. </form>

</body>
</html>
```

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议