用户注册表单以及选择器权重与上下文选择器


一、from 用户注册表单

  • 用户注册表单效果图

实例演示 from 用户注册表单

  • 代码语言
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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. </head>
  9. <body>
  10. <h2 class="ye">用户注册</h2>
  11. <!-- http://127.0.0.1:5500/0922/tijiaofuwuqi.php =POST -->
  12. <!-- http://127.0.0.1:5500/0922/dome.html?username= GET -->
  13. <!-- 表单form用户注册 -->
  14. <form action="tijiaofuwuqi.php" method="POST">
  15. <!-- <fieldset></fieldset> 给表单元素周围加个边框 -->
  16. <fieldset>
  17. <legend style="text-align: center">必填项</legend>
  18. <!-- 单行文本 -->
  19. <!-- 绑定账号标签 -->
  20. <div>
  21. <label for="username"> 账号:</label>
  22. <!-- 文本框 -->
  23. <!-- *绑定ID -->
  24. <input
  25. type="text"
  26. id="username"
  27. name="username"
  28. placeholder="不超过8位"
  29. required
  30. autofocus
  31. value="1827673"
  32. />
  33. </div>
  34. <div>
  35. <label for="password"> 密码:</label>
  36. <input
  37. type="password"
  38. id="passtword"
  39. name="password"
  40. placeholder="不超过8位"
  41. required
  42. />
  43. <!-- 显示密码 -->
  44. <!-- <button type="button" onclick="document.querySelector('#password').type='text'">显示密码</button> -->
  45. <!-- 按钮 -->
  46. </div>
  47. <div>
  48. <label for="email"> 邮箱:</label>
  49. <input
  50. type="email"
  51. id="email"
  52. name="email"
  53. placeholder="demo@email.com"
  54. required
  55. />
  56. </div>
  57. </fieldset>
  58. <!-- 单选按钮 -->
  59. <div>
  60. <label for="secret">性别</label>
  61. <!-- 单选按钮中的name属性,必须全部一样,才能保证返回唯一值 -->
  62. <input type="radio" name="gender" id="male" value="male" /><label
  63. for="male"
  64. ></label
  65. >
  66. <input type="radio" name="gender" id="female" value="female" /><label
  67. for="female"
  68. ></label
  69. >
  70. <!-- checked布尔属性,不需要值,只要存在就是true -->
  71. <input
  72. type="radio"
  73. name="gender"
  74. id="secret"
  75. value="secret"
  76. checked
  77. /><label for="secret">保密</label>
  78. </div>
  79. <!-- 复选框 -->
  80. <!-- []表示数组,可以保存一组不同类型的数据,供后端使用 -->
  81. <div>
  82. <label>爱好</label>
  83. <!-- 单选按钮中的name属性,必须全部一样,才能保证返回唯一值 -->
  84. <input
  85. type="checkbox"
  86. name="hobby[]"
  87. id="game"
  88. value="game"
  89. checked
  90. /><label for="game">游戏</label>
  91. <input type="checkbox" name="hobby[]" id="trave" value="trave" /><label
  92. for="trave"
  93. >旅游</label
  94. >
  95. <!-- checked布尔属性,不需要值,只要存在就是true -->
  96. <input
  97. type="checkbox"
  98. name="hobby[]"
  99. id="shoot"
  100. value="shoot"
  101. checked
  102. /><label for="shoot">摄影</label>
  103. </div>
  104. <div>
  105. <!-- 下拉列表,将变量名和多个值分开设置,由用户自己选择 -->
  106. <!-- name,value应该在一个标签内,但是select -->
  107. <select name="level">
  108. <option value="1">铜牌会员</option>
  109. <option value="2">银牌会员</option>
  110. <option value="3" selected>金牌会员</option>
  111. <option value="4">永久会员</option>
  112. </select>
  113. </div>
  114. <!-- 自定义下拉列表 -->
  115. <!-- datalist+ input -->
  116. <div>
  117. <label for="">搜索关键字:</label>
  118. <input type="search" name="search" list="keywords" />
  119. <datalist id="keywords">
  120. <option value="html">html</option>
  121. <option value="css">css</option>
  122. <option value="css">css</option>
  123. <option value="css">css</option>
  124. </datalist>
  125. </div>
  126. <button>提交</button>
  127. <!-- 重置按钮 重置不是清空-->
  128. <button type="reset">重置</button>
  129. </form>
  130. </body>
  131. </html>

二、选择器权重

选择器的特殊性值表述为 3 个部分,用 0,0,0 表示。或者百[id],十[class],个[tag]/标签
ID 选择器,1,0,0。
class 类选择器,0,1,0。
标签,0,0,1。
通配选择器*对特殊性没有贡献,即 0,0,0。
最后比较特殊的一个标志!important(权重),它没有特殊性值,但它的优先级是最高的,通常 !important 用在样式调试的时候 。

  • 选择器权重效果图

实例演示 权重关系

  • 代码语言
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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. <style>
  9. /* 选择当前的h3有三种选择器;
  10. 标签,class,id */
  11. /* 将id,class,tag,想像成一个三位整数,初始为0,0,0 */
  12. /* 百位 十位 个数 */
  13. /* id class tag */
  14. /* 0 0 0 */
  15. /* 百位对应:id
  16. 十位对应:class
  17. 个位对应:tag */
  18. /* 当前权重0,0,1 */
  19. h3 {
  20. background-color: burlywood;
  21. }
  22. /* 当前权重0,0,2 */
  23. body h3 {
  24. background-color: coral;
  25. }
  26. /* 当前权重0,0,3 */
  27. html body h3 {
  28. background-color: cornflowerblue;
  29. }
  30. /* 当前权重0,1,0 */
  31. .b {
  32. background-color: crimson;
  33. }
  34. /* 当前权重0,1,1 */
  35. h3.b {
  36. background-color: darkblue;
  37. }
  38. /* 当前权重1,0,0 */
  39. #a {
  40. background-color: darkorange;
  41. }
  42. /* 当前权重1,1,0 */
  43. #a.b {
  44. background-color: deeppink;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <!-- *权重关系 -->
  50. <h3 id="a" class="b">人生苦短,我学PHP</h3>
  51. </body>
  52. </html>

三、上下文选择器

  • 上下文选择器效果图

    实例演示 上下文选择器

  • 代码语言

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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. <style>
  9. /* 子元素选择器 > */
  10. .list > li {
  11. border: 1px solid red;
  12. }
  13. /* 后代选择器 空格 */
  14. .list li {
  15. border: 1px solid black;
  16. }
  17. .list .liem {
  18. background-color: aquamarine;
  19. }
  20. /* 相邻选择器 /下一个+ */
  21. .list .liem + li {
  22. background-color: bisque;
  23. }
  24. /* 所有兄弟选择器 */
  25. .list .liem ~ * {
  26. background-color: rebeccapurple;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <ul class="list">
  32. <li>ltem1</li>
  33. <li class="liem">ltem2</li>
  34. <li>
  35. ltem3
  36. <!-- <ul>
  37. <li>ltem1</li>
  38. <li>ltem2</li>
  39. </ul> -->
  40. </li>
  41. <li>ltem4</li>
  42. <li>ltem5</li>
  43. <li>ltem6</li>
  44. <li>ltem7</li>
  45. <li>ltem8</li>
  46. </ul>
  47. </body>
  48. </html>

更多相关文章

  1. 表单制作和选择器
  2. HTML表单与选择器学习与应用
  3. html注册页面-表单
  4. 网站外链建设注意事项有哪些
  5. 域名对SEO优化到底有多大影响!
  6. 如何优化网站权重页?
  7. html表单、元素的来源及csss外部样式和上下文选择器
  8. html练习之表单标签使用
  9. HTML表单内容的详细介绍

随机推荐

  1. android proground混淆编译
  2. Android(安卓)中的BroadCastReceiver
  3. AudioRecord||AudioTrack
  4. android的唯一性
  5. 上官网学android之二(Building your First
  6. Android(安卓)属性动画(二)
  7. Android(安卓)- Handler is abstract, ca
  8. Android ID
  9. Android下so注入汇总
  10. android 神奇的android:clipChildren属性