Blogger Information
Blog 12
fans 0
comment 2
visits 6323
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
权重伪类学习
白鸽
Original
691 people have browsed it

权重伪类

伪类还不是很熟练,但理解了。权重没有彻底掌握,理解上也存在偏差,我理解的权重是样式继承嵌套中的优先使用先后顺序。


  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>css选择器</title>
  8. <style>
  9. h1{
  10. color:red;
  11. }
  12. h1.green{
  13. color:green;
  14. }
  15. .blue{
  16. color:blue;
  17. }
  18. .blue.max{
  19. font-size: 5em;
  20. }
  21. p.pcolor{
  22. color:brown;
  23. }
  24. .ccc p{
  25. color:aqua;
  26. }
  27. .ccc h1{
  28. color: lightgreen;
  29. }
  30. .box li:nth-of-type(1) {
  31. color:magenta;
  32. }
  33. .box2 li:nth-last-of-type(1){
  34. color: green;
  35. }
  36. .box3 li:nth-of-type(-n+3){
  37. color: red;
  38. }
  39. #box4{
  40. color: blue;
  41. }
  42. #box4 h1{
  43. color:blue;
  44. }
  45. #box4 p{
  46. color:darkred;
  47. }
  48. #box4 span{
  49. color:red;
  50. }
  51. #box4 p span{
  52. color:cornflowerblue;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <h1>我是红色的h1</h1>
  58. <h1 class="green">我是绿色的h1</h1>
  59. <h1 class="blue">我是蓝色的h1</h1>
  60. <p class="green">我会是绿色的吗?</p>
  61. <p>上面的p,无法继承绿色的h1的设置,class=green只适合h1标签。</p>
  62. <h1 class="max">我会是变大吗?</h1>
  63. <p class="pcolor">我会是 brown 的颜色吗?</p>
  64. <div class="ccc"><p>我的颜色是aqua</p>
  65. <h1>哈哈笑</h1></div>
  66. <hr>
  67. <div>
  68. <h1>伪类</h1>
  69. <ul class="box">
  70. <li class="list">我的颜色是magenta</li>
  71. <li class="list">list-2</li>
  72. <li class="list">list-3</li>
  73. <li class="list">list-4</li>
  74. </ul>
  75. </div>
  76. <hr>
  77. <div class="box2">
  78. <ul>
  79. <li>list-1</li>
  80. <li>list-2</li>
  81. <li>list-3</li>
  82. <li>我是绿色的</li>
  83. </ul>
  84. </div>
  85. <hr>
  86. <div class="box3">
  87. <ul>
  88. <li>前三</li>
  89. <li>list-2</li>
  90. <li>list-3</li>
  91. <li>list-4</li>
  92. <li>list-5</li>
  93. <li>list-6</li>
  94. <li>list-7</li>
  95. <li>list-8</li>
  96. <li>list-9</li>
  97. <li>list-10</li>
  98. </ul>
  99. </div>
  100. <hr>
  101. <div id="box4">
  102. <h1>这次我应该是蓝色的了吧</h1>
  103. <p>这一行是box4下的p标签<span>什么span</span></p>
  104. </div>
  105. </body>
  106. </html>
  107. `
Correcting teacher:PHPzPHPz

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