Blogger Information
Blog 12
fans 0
comment 0
visits 6602
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
HTML 用户表单
Giesen?
Original
581 people have browsed it

用户表单注册

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>用户注册表单</title>
  8. <link rel="stylesheet" href="zycss/zy.css" />
  9. </head>
  10. <body>
  11. <!-- 页眉 -->
  12. <div id="header">
  13. <header class="zc">用户注册表</header>
  14. </div>
  15. <div id="container">
  16. <!-- 左边栏 -->
  17. <aside class="left"></aside>
  18. <!-- 中间栏 -->
  19. <main class="content">
  20. <form class="bd" action="" method="get" onsbmit="return false">
  21. <!-- 用户注册 账号 密码 邮箱 文本框 input标签 -->
  22. <fieldset>
  23. <legend>必填项</legend>
  24. <div>
  25. <label for="username"> 账号:</label>
  26. <input
  27. type="text"
  28. id="username"
  29. name="username"
  30. required
  31. autofocus
  32. placeholder="不得少于6位"
  33. />
  34. </div>
  35. <div>
  36. <label for="emil">邮箱:</label>
  37. <input
  38. type="email"
  39. name="email"
  40. id="email"
  41. required
  42. placeholder="ass@email.com"
  43. />
  44. </div>
  45. <div>
  46. <label for="psw"> 密码:</label>
  47. <input
  48. type="password"
  49. id="psw"
  50. name="psw"
  51. required
  52. placeholder="建议密码包含大小写"
  53. />
  54. </div>
  55. </fieldset>
  56. <!-- 性别单选按钮 -->
  57. <div>
  58. <!-- 单选按钮 -->
  59. <label for="secret">性别</label>
  60. <input type="radio" name="gender" value="nan" /><label for=""
  61. ></label
  62. >
  63. <input type="radio" name="gender" value="nue" /><label for=""
  64. ></label
  65. >
  66. <input
  67. type="radio"
  68. name="gender"
  69. value="secret"
  70. checked
  71. id="secret"
  72. /><label for="">保密</label>
  73. </div>
  74. <div class="Habby">
  75. <!-- 复选框 input type="checkbox"-->
  76. <!-- 所有复选框的name属性标签必须写成数组格式 -->
  77. <label for="game">爱好</label>
  78. <input type="checkbox" name="Habby[]" id="game" checked /><label for="game">
  79. 游戏</label
  80. >
  81. <input type="checkbox" name="Habby[]" id="film" /><label for="film">
  82. 电影</label
  83. >
  84. <input type="checkbox" name="Habby[]" id="music" /><label for="music">
  85. 音乐</label
  86. >
  87. <input type="checkbox" name="Habby[]" id="read" /><label for="read">
  88. 阅读</label
  89. >
  90. <!-- input标签中 添加checked 属性则默认选中 -->
  91. </div>
  92. <div class="school">
  93. <!-- 下拉列表 -->
  94. <label for="">所在的学校:</label>
  95. <select name="school" id="">
  96. <option value="1">深圳大学</option>
  97. <option value="1">北京大学</option>
  98. <option value="1">清华大学</option>
  99. </select>
  100. </div>
  101. <div>
  102. <!-- 自定义下拉列表, select + input = datalist -->
  103. <label for="">所属的社团:</label>
  104. <input type="search" name="societies" list="societies" />
  105. <datalist id="societies">
  106. <option value="街舞社"></option>
  107. <option value="魔术社"></option>
  108. <option value="模特社"></option>
  109. </datalist>
  110. </div>
  111. <div>
  112. <button>提交</button>
  113. </div>
  114. </form>
  115. </main>
  116. <!-- 右边栏 -->
  117. <aside class="right"></aside>
  118. </div>
  119. <!-- 页脚 -->
  120. <footer class="yw">备注:请大家尽快注册,明天下午6点之前完成</footer>
  121. </body>
  122. </html>

CSS样式表

zy.css

  1. @import url(main.css);
  2. @import url(footer.css);
  3. @import url(header.css);

main.css

  1. #container {
  2. margin: 5px 0;
  3. display: flex;
  4. justify-content: center;
  5. }
  6. #container .left,
  7. #container .right {
  8. min-width: 40%;
  9. min-height: 600px;
  10. }
  11. #container .content {
  12. flex: 1;
  13. margin: 0 5px;
  14. }
  15. #container div{
  16. text-align: left;
  17. }
  18. /* 使用上下文选择器 对下拉框选择 */
  19. .school>select{
  20. width: 180px;
  21. }
  22. .bd{
  23. display:grid;
  24. gap: 5em;
  25. }

header.css

  1. .zc{
  2. width: 100%;
  3. vertical-align: middle;
  4. text-align: center;
  5. font-size: 40px;
  6. }
  1. .yw{
  2. width: 100%;
  3. vertical-align: middle;
  4. text-align: center;
  5. font-size: 40px;
  6. }

上下文选择器实例

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. /* 后代选择器 子子孙孙都会选中 */
  10. .sg li{
  11. background-color: aquamarine;
  12. }
  13. .sg>li{
  14. background-color: blue;
  15. }
  16. .cm+li{
  17. background-color: blueviolet;
  18. }
  19. .cm~li{
  20. background-color: brown;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <ul class="sg">
  26. <li>苹果
  27. <ul>
  28. <li>大苹果</li>
  29. <li>小苹果</li>
  30. </ul>
  31. </li>
  32. <li>香蕉</li>
  33. <li>西瓜</li>
  34. <li class="cm">草莓</li>
  35. <li>樱桃</li>
  36. <li>龙眼</li>
  37. </ul>
  38. </body>
  39. </html>

总结

  • 学习了Form标签和input标签的应用,单选和多选框,下拉框和自定义下拉框的应用,结合前面所学的元素布局以及CSS的模块化如何应用在案例中

  • 熟悉了CSS的标签,属性和上下文选择器

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post