Blogger Information
Blog 28
fans 0
comment 0
visits 11759
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
10.20作业
子墨吖ฅฅ
Original
287 people have browsed it

css选择器权重及伪类选择器的使用

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. /*权重为0 0 1*/
  8. h1{
  9. color: yellow;
  10. }
  11. /*此时h1标签显示为黄色*/
  12. /*权重为0 1 1*/
  13. h1.title{
  14. color:red;
  15. }
  16. /*此时h1标签内容显示为红色*/
  17. /*权重为1 0 0*/
  18. h1.title#title{
  19. color: blue;
  20. }
  21. /*此时h1标签内容显示为蓝色*/
  22. /* 提升权重 */
  23. /* 权重为 1 1 2 */
  24. body > h1.title#title{
  25. color: pink;
  26. }
  27. /*此时h1标签内容显示为粉色*/
  28. /* 伪类使用方法 */
  29. .list>.item:first-of-type{
  30. color: red;
  31. }
  32. /*使ul下面的第一个li标签内容显示为红色*/
  33. .list>.item:last-of-type{
  34. color: red;
  35. }
  36. /*使ul下面的最后一个li标签内容显示为红色*/
  37. .list>.item:nth-of-type(n+3){
  38. color: blue;
  39. }
  40. /*使ul下面的从第三个标签开始后面的li标签的内容变为蓝色*/
  41. .list>.item:nth-of-type(-n+3){
  42. color: pink;
  43. }
  44. /*使ul下面的从第三个标签开始前面的li标签的内容变为蓝色*/
  45. </style>
  46. </head>
  47. <body>
  48. <h1 class="title" id="title">权重权重权重</h1>
  49. <ul class="list">
  50. <li class="item">内容</li>
  51. <li class="item">内容</li>
  52. <li class="item">内容</li>
  53. <li class="item">内容</li>
  54. <li class="item">内容</li>
  55. <li class="item">内容</li>
  56. <li class="item">内容</li>
  57. <li class="item">内容</li>
  58. </ul>
  59. </body>
  60. </html>
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