Blogger Information
Blog 27
fans 1
comment 2
visits 90442
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
结构伪类和css权重
          
Original
409 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>10.20作业</title>
  6. <!-- 要求:-->
  7. <!-- 1. 实例演示权重的原理与计算方式 -->
  8. <!-- 2. 实例演示结构伪类,通过位置关系匹配子元素-->
  9. <style>
  10. .show>h3{color: #2D93CA;}
  11. body>pre#a1{color: chocolate;}
  12. </style>
  13. </head>
  14. <body>
  15. <h3>作业一:1. 实例演示权重的原理与计算方式</h3>
  16. <pre id="a1">权重规则:
  17. 1. 实体标记: id, class, tag
  18. 2. 排列顺序: id, class, tag
  19. 3. 记数方式: 选择器中的实体标记数量</pre>
  20. <div class="show"><h3>演示:</h3>
  21. body>pre#a1{color: chocolate;} >>> 权重是:(1,0,2) 计算方式:#a1表示id=1, 本次没有class标签 class=0 body和pre属于标签,也就tag=2
  22. <hr>
  23. .show>h3{color: #2D93CA;} >>> 权重是:(0,1,1) 计算方式:无id &nbsp; .show = class为1 h3 = tag为1,所以(0,1,1)=>(id,class,tag)
  24. </div>
  25. <h3>作业二: 2. 实例演示结构伪类,通过位置关系匹配子元素</h3>
  26. <ul>
  27. <li class="his">item-1</li>
  28. <li class="his">item-2</li>
  29. <li class="his">item-3</li>
  30. <li class="his">item-4</li>
  31. <li class="his">item-5</li>
  32. </ul>
  33. <style>
  34. /*获取第4个标签改为绿色*/
  35. ul>li:nth-of-type(4){
  36. background-color: green;
  37. }
  38. /*获取最后一个标签改为蓝色 切结last-of-type不要加括号,没有值*/
  39. ul>li:last-of-type{
  40. background-color: dodgerblue;
  41. }
  42. /*
  43. ! :nth-of-type(an + b)
  44. * 1. a: 系数, [0,1,2,3,...]
  45. * 2. n: 参数, [0,1,2,3,...]
  46. * 3. b: 偏移量, 从0开始
  47. ? 规则: 计算出来的索引,必须是有效的(从1开始)
  48. /*获取前面三个item1~item3,字体颜色改为红色*/
  49. ul>li:nth-of-type(-n+3){
  50. color: red;
  51. }
  52. /*!*获取第一个,字体颜色改为黄色*!*/
  53. ul>li:nth-of-type(1){
  54. color: yellow;
  55. }
  56. </style>
  57. </body>
  58. </html>

运行结果:

10.20作业

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