Blogger Information
Blog 18
fans 0
comment 0
visits 10891
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
用户注册表单与css选择器
手机用户1631860753
Original
383 people have browsed it

一.用户注册表

  • 输入:
    1. <h2>用户注册</h2>
    2. <form action="check.php" method="POST" style="display: grid; gap: 0.5em">
    3. <fieldset>
    4. <legend>必填项</legend>
    5. <div>
    6. <label for="username">账号:</label>
    7. <input
    8. type="text"
    9. id="username"
    10. name="username"
    11. placeholder="请输入用户名或者手机号"
    12. required
    13. autofocus
    14. value="17746943541"
    15. />
    16. </div>
    17. <div>
    18. <label for="psw">密码:</label>
    19. <input type="password" id="psw" name="psw" placeholder="请输入不少于8位密码" required />
    20. <button type="button" onclick="document.querySelector('#psw').type='text'">显示密码</button>
    21. </div>
    22. <div>
    23. <label for="email">邮箱:</label>
    24. <input type="email" id="email" name="email" placeholder="295885@email.com" required />
    25. </div>
    26. <div>
    27. <label for="verification">验证:</label>
    28. <input type="verification" id="verification" name="verification" placeholder="请输入验证码" required />
    29. </div>
    30. </fieldset>
    31. <fieldset>
    32. <legend>选填项</legend>
    33. <div>
    34. <label for="secret">性别:</label>
    35. <input type="radio" name="gender" id="male" value="male" /><label for="male"></label>
    36. <input type="radio" name="gender" id="female" value="female" /><label for="female"></label>
    37. <input type="radio" name="gender" id="secret" value="secret" checked /><label for="secret">保密</label>
    38. </div>
    39. <div>
    40. <label>爱好:</label>
    41. <input type="checkbox" name="hobby[]" id="game" checked /><label for="game">游戏</label>
    42. <input type="checkbox" name="hobby[]" id="basketball" /><label for="basketball">篮球</label>
    43. <input type="checkbox" name="hobby[]" id="game" checked /><label for="game">游戏</label>
    44. <input type="checkbox" name="hobby[]" id="swim" /><label for="swim">游泳</label>
    45. </div>
    46. <div>
    47. <label>居住城市:</label>
    48. <select name="site">
    49. <option value="1">北京</option>
    50. <option value="2" selected>成都</option>
    51. <option value="3">上海</option>
    52. <option value="4">北京</option>
    53. <option value="5">深圳</option>
    54. </select>
    55. </div>
    56. <div>
    57. <label for="">居住地址:</label>
    58. <input type="search" name="search" list="keywords" />
    59. <datalist id="keywords">
    60. <option value="锦江区">锦江区</option>
    61. <option value="金牛区">金牛区</option>
    62. <option value="青羊区">青羊区</option>
    63. </datalist>
    64. </div>
    65. </fieldset>
    66. <button>注册</button>
    67. <button>登录</button>
    68. </form>
  • 输出:

二.选择器

1.选择器权重

1.1. 三大通用元素:style,id,class,适用于几乎所有的元素;
1.2. 优先级属性:!important > style属性 > id > class > tag(tag是标签)

!important 最优先级,一般用于样式的调试,很少用;class 比较常用。

1.3. id , class , tag 默认权重关系,初始默认都为0 , 0 , 0。

id class tag
0 0 0
百位 十位 个位

权重对比:

  • 输入:

    权重:0,0,1

    1. <h2 id="a" class="b">选择器权重计算</h2>
    2. <style>
    3. h2 {
    4. color: red;
    5. background-color: yellow;
    6. }
  • 输出:

  • 输入:

    权重:0,0,2

    1. <h2 id="a" class="b">选择器权重计算</h2>
    2. <style>
    3. h2 {
    4. color: red;
    5. background-color: yellow;
    6. }
    7. body h2 {
    8. background-color: violet;
    9. }
  • 输出:
  • 输入:

    权重:0,1,0

    1. <h2 id="a" class="b">选择器权重计算</h2>
    2. <style>
    3. h2 {
    4. color: red;
    5. background-color: yellow;
    6. }
    7. body h2 {
    8. background-color: violet;
    9. }
    10. .b {
    11. background-color: teal;
    12. }
  • 输出:

  • 输入:

    权重:0,1,1

    1. <h2 id="a" class="b">选择器权重计算</h2>
    2. <style>
    3. h2 {
    4. color: red;
    5. background-color: yellow;
    6. }
    7. body h2 {
    8. background-color: violet;
    9. }
    10. .b {
    11. background-color: teal;
    12. }
    13. h2.b {
    14. background-color: tomato;
    15. }
  • 输出:

  • 输入:

    权重:1,0,0

    1. <h2 id="a" class="b">选择器权重计算</h2>
    2. <style>
    3. h2 {
    4. color: red;
    5. background-color: yellow;
    6. }
    7. body h2 {
    8. background-color: violet;
    9. }
    10. .b {
    11. background-color: teal;
    12. }
    13. h2.b {
    14. background-color: tomato;
    15. }
    16. #a {
    17. background-color: cyan;
    18. }
  • 输出:

  • 输入:

    最大优先级:!important

    1. <h2 id="a" class="b">选择器权重计算</h2>
    2. <style>
    3. h2 {
    4. color: red;
    5. background-color: yellow !important;
    6. }
    7. body h2 {
    8. background-color: violet;
    9. }
    10. .b {
    11. background-color: teal;
    12. }
    13. h2.b {
    14. background-color: tomato;
    15. }
    16. #a {
    17. background-color: cyan;
    18. }
  • 输出:

2.上下文选择器

子元素选择用大于号“>”;
后代元选择用空格“ ”;
相邻元素选择用加号“+”;
选中全部兄弟元素用波浪号“~”;

选择不同的元素

  • 输入:
    1. <ul class="list">
    2. <li>demo1</li>
    3. <liclass="demo">demo2</li>
    4. <li>demo3
    5. <ul>
    6. <li>demo01</li>
    7. <li>demo02</li>
    8. <li>demo03</li>
    9. </ul>
    10. </li>
    11. <li>demo4</li>
    12. <li>demo5</li>
    13. </ul>
  • 输出:
给子元素添加边框
  • 输入:
    1. <style>
    2. .list > li {
    3. border: 1px solid #000;
    4. }
    5. </style>
  • 输出:
  • “>”只是给子元素添加边框,后代元素不添加
添加边框
  • 输入:
    1. <style>
    2. .list li {
    3. border: 1px solid #000;
    4. }
    5. </style>
  • 输出:
  • 空格符号选择后代元素一起添加表格
选择元素
  • 输入:
    1. <style>
    2. .list > li {
    3. border: 1px solid #000;
    4. }
    5. .list li {
    6. border: 1px solid #000;
    7. }
    8. .list .demo {
    9. background-color: chocolate;
    10. }
    11. </style>
  • 输出:
  • 选中当前元素

  • 输入:

    1. <style>
    2. .list > li {
    3. border: 1px solid #000;
    4. }
    5. .list li {
    6. border: 1px solid #000;
    7. }
    8. .list .demo + * {
    9. background-color: chocolate;
    10. }
    11. </style>
  • 输出:
  • 加上加号就是选中当前元素的相邻的下一个元素
  • 输入:
    1. <style>
    2. .list > li {
    3. border: 1px solid #000;
    4. }
    5. .list li {
    6. border: 1px solid #000;
    7. }
    8. .list .demo ~ * {
    9. background-color: cyan;
    10. }
    11. </style>
  • 输出:
  • 加上波浪号就是选中当前元素的所有兄弟元素
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:<style>是内部样式
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