制作一个用户注册表单,尽可能将常用控件都用一遍

  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. </head>
  9. <body>
  10. <h2>用户注册</h2>
  11. <!--GET: 数据在url中,文明发送,适合少量数据,不超过4k-->
  12. <!--post: 数据在请求体中,不在url中,安全,可发送大量的数据,例如文件上传-->
  13. <form action="check.php" method="POST" style="display: grid; gap: 0.5em">
  14. <fieldset>
  15. <legend>必填项</legend>
  16. <div>
  17. <!--单行文本框-->
  18. <label for="username">账号</label>
  19. <input
  20. type="text"
  21. id="username"
  22. name="username"
  23. placeholder="用户名"
  24. required
  25. autofocus
  26. />
  27. </div>
  28. <div>
  29. <label for="psw">密码</label>
  30. <input
  31. type="password"
  32. id="psw"
  33. name="psw"
  34. placeholder="密码"
  35. required
  36. autofocus
  37. />
  38. <!--<button type="button" onclick="document.querySelector('#psw').type='text'" >显示密码 </button> -->
  39. </div>
  40. <div>
  41. <label for="email">邮箱</label>
  42. <input
  43. type="email"
  44. id="email"
  45. name="email"
  46. placeholder="123123@qq.com"
  47. required
  48. autofocus
  49. />
  50. </div>
  51. <!--checked布尔属性,不需要值,只要存在就是true /真-->
  52. </fieldset>
  53. <!--单选框-->
  54. <div>
  55. <label for="secret">性别:</label>
  56. <!--单选按钮中的name属性,必须全部一样,才能保证返回唯一值-->
  57. <input type="radio" name="gender" id="male" value="male" />
  58. <label for="male"></label>
  59. <input type="radio" name="gender" id="female" value="female" />
  60. <label for="female"></label>
  61. <input type="radio" name="gender" id="secret" value="secret" checked />
  62. <label for="secret">保密</label>
  63. <!--checked布尔属性,不需要值,只要存在就是true /真-->
  64. </div>
  65. <!--复选框-->
  66. <div>
  67. <label for="secret">爱号:</label>
  68. <!--单选按钮中的name属性,必须全部一样,才能保证返回唯一值-->
  69. <!--bobby[]表示数组,可以保存一组不同类型的数据,供后端调用-->
  70. <input type="checkbox" name="hobby[]" id="game" value="game" />
  71. <label for="game">游戏</label>
  72. <input type="checkbox" name="hobby[]" id="trvae" value="trvae" />
  73. <label for="trvae">旅游</label>
  74. <input
  75. type="checkbox"
  76. name="hobby[]"
  77. id="shoot"
  78. value="shoot"
  79. checked
  80. />
  81. <label for="shoot">摄影</label>
  82. <!--checked布尔属性,不需要值,只要存在就是true /真-->
  83. </div>
  84. <div>
  85. <!--下拉列表,将变量名和多个值分开设置,由用户自己选择-->
  86. <!--name,vlaue应该在一个标签内,但是select-->
  87. <select name="" id="">
  88. <option value="1">铜牌会员</option>
  89. <option value="2">银牌会员</option>
  90. <option value="3" selected>金牌会员</option>
  91. <option value="4">永久会员</option>
  92. </select>
  93. </div>
  94. <!--自定义下拉列表-->
  95. <!--datalist+input-->
  96. <div>
  97. <label for="">搜索关键词:</label>
  98. <input type="search" name="search" list="keywords" />
  99. <datalist id="keywords">
  100. <option value="html">html</option>
  101. <option value="css">css</option>
  102. <option value="js">js</option>
  103. <option value="javascript">javascript</option>
  104. </datalist>
  105. </div>
  106. <button>提交</button>
  107. <!--重置不是清空,是恢复到默认值-->
  108. <button type="reset">重置</button>
  109. <!--不想提交,想自定义提交验证的规则,例如异步ajax提交-->
  110. </form>
  111. </body>
  112. </html>

2. 实例演示选择器权重的计算过程;

  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. <!--style标签设置样式,适合于当前html文档,内部样式/文档样式-->
  9. <style>
  10. /* 1,浏览器默认样式
  11. h2 {
  12. display: block;
  13. font-size: 1.5em;
  14. margin-block-start: 0.83em;
  15. margin-block-end: 0.83em;
  16. margin-inline-start: 0px;
  17. margin-inline-end: 0px;
  18. font-weight: bold;
  19. }
  20. */
  21. /* 2,用户自定义样式*/
  22. /*
  23. h1 {
  24. color: brown;
  25. background-color: yellow;
  26. }
  27. */
  28. </style>
  29. </head>
  30. <body>
  31. hello world
  32. <h1 id="title">hello world</h1>
  33. <!--style属性: 行内样式,仅限于当前元素-->
  34. <h1 style="color: tomato">hello world</h1>
  35. <!--浏览器不检查id的唯一性,唯一性由程序员自己确保-->
  36. <h2 id="title">大家晚上听得很认真</h2>
  37. <style>
  38. /* 选择器: 用于选择页面中一个或多个元素的字符串*/
  39. /*选择器 {
  40. 声明1;
  41. 声明2;
  42. }*/
  43. /* 选择器 +声明块 +规则 */
  44. /* [id="title"] {
  45. color: brown;
  46. background-color: yellow;
  47. }
  48. */
  49. #title {
  50. color: #000;
  51. background-color: turquoise;
  52. }
  53. </style>
  54. <p class="demo">今晚我吃的很棒</p>
  55. <h2 class="demo">css其实很有意思</h2>
  56. <style>
  57. [class="demo"] {
  58. color: tomato;
  59. background-color: blanchedalmond;
  60. }
  61. .demo {
  62. color: blue;
  63. background-color: crimson;
  64. }
  65. </style>
  66. <h2 style="color: crimson" id="test" class="aaa">猪老师</h2>
  67. <style>
  68. h2 {
  69. color: blue !important;
  70. /*--!important 用在样式的调试--*/
  71. }
  72. .aaa {
  73. color: crimson;
  74. }
  75. #test {
  76. color: darkgreen;
  77. }
  78. /*--css里面!important大于style大于id大于class大于tag--*/
  79. </style>
  80. <!--三大通用属性;几乎所有的元素都可以使用的属性-->
  81. <!--属性style id class 背下来-->
  82. <h3 id="a" class="b">你好啊</h3>
  83. <style>
  84. /*选择当前的h3有三种选择器:
  85. 标签 class id*/
  86. /* 将id,class,tag,想象成一个三位整数,初始为0,0,0 */
  87. /*百位 十位 个数
  88. id class tag
  89. 0 0 0 */
  90. /*百位对应;id
  91. 十位对应:class
  92. 个位对应:tag */
  93. /*id权重大于class大于tag*/
  94. /*1 1 0*/
  95. #a .b {
  96. background-color: indigo;
  97. }
  98. /*1 0 0*/
  99. #a {
  100. background-color: indigo;
  101. }
  102. /*0 1 1*/
  103. h3 .b {
  104. background-color: goldenrod;
  105. }
  106. /*0 1 0*/
  107. .b {
  108. background-color: darkolivegreen;
  109. }
  110. /* 0 0 2*/
  111. body h3 {
  112. color: darkslategrey;
  113. }
  114. /*0 0 1*/
  115. h3 {
  116. color: dodgerblue;
  117. }
  118. /*为什么要学他,因为有许多框架有原始的样式表,这些不能动*/
  119. /*element ui , layui bootstrap ....*/
  120. .col-md-3 {
  121. }
  122. div.clo-md-3 {
  123. /*这样就可以放心的写自己的代码了,不必担心原始的框架源码,为什么?因为权重最大直接覆盖*/
  124. }

上下文选择器

  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. </head>
  9. <body>
  10. <ul class="list">
  11. <li>item1</li>
  12. <li class="item">item2</li>
  13. <li>item3</li>
  14. <ul>
  15. <li>item1</li>
  16. <li>item2</li>
  17. <li>item3</li>
  18. </ul>
  19. <li>item4</li>
  20. <li>item5</li>
  21. <li>item6</li>
  22. <li>item7</li>
  23. <li>item8</li>
  24. </ul>
  25. <style>
  26. /*子元素>>>*/
  27. .list > li {
  28. border: 1px solid mediumblue;
  29. }
  30. /*后代 空格*/
  31. .list li {
  32. border: 1px solid mediumblue;
  33. }
  34. /*相邻;+*/
  35. .list .item + * {
  36. background-color: mediumvioletred;
  37. }
  38. /*所有兄弟全选中;~ */
  39. .list .item ~ * {
  40. background-color: mediumvioletred;
  41. }
  42. </style>
  43. </body>
  44. </html>

更多相关文章

  1. HTML常用标签的用法示例
  2. 1.模态框 2.flex布局 3.grid属性
  3. CSS盒模型常用属性,单位,选择器
  4. 绝对定位、固定定位及flex,grid属性
  5. 1.box-sizing属性 2.伪类选择器 3.媒体查询
  6. Flex与grid属性思维导图
  7. Nofollow属性的介绍和使用
  8. HTML表单与选择器学习与应用
  9. CSS 元素样式来源

随机推荐

  1. 嘿,你知道新冠疫情现在什么样了吗?
  2. C#基础入门第十四天(MD5加密,WinForm)
  3. 啥是佩奇排名算法
  4. Python与Tableau相结合,万字长文搞定传统
  5. 图解LeetCode第 279 号问题: 完全平方数
  6. Android(安卓)- 引用计数(sp、wp、Refbase
  7. 时间序列&日期学习笔记大全(上)
  8. 图解LeetCode第 445 号问题: 两数相加 II
  9. 图解LeetCode第 199 号问题:二叉树的右视
  10. 使用RxJs WebSocket,HighCharts和Angular