Blogger Information
Blog 16
fans 0
comment 0
visits 6863
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
权重的原理与计算方式,伪类指定一个实际参数nth-of-type(an+b)
Stonegarlic
Original
308 people have browsed it

1020作业

1.上下文选择器

  1. <ul class="list">
  2. <li class="item">item-1</li>
  3. <li class="item">item-2</li>
  4. <li class="item">item-3</li>
  5. <li class="item">item-4
  6. <ul class="item">sunzi1</ul>
  7. <ul class="item">sunzi2</ul>
  8. <ul class="item">sunzi3</ul>
  9. </li>
  10. <li class="item five">item-5</li>
  11. <li class="item six">item-6</li>
  12. <li class="item">item-7</li>
  13. <li class="item">item-8</li>
  14. </ul>
  1. .list > li:nth-of-type(3){
  2. color: red;
  3. }
  4. /* 获取第一个 语法糖*/
  5. .list > li:first-of-type{
  6. color: red;
  7. }
  8. /* 获取最后一个 语法糖 */
  9. .list > li:last-of-type{
  10. color: red;
  11. }
  12. .box{
  13. width: 100px;
  14. height: 150px;
  15. border: 1px red;
  16. }

实例效果

2.选择器的权重

  1. <p class="one">css1</p>
  2. <h1 class="al-3 color bgc">css2</h1>
  3. <h1>css3</h1>
  4. <h1>css4</h1>
  5. <h1>css5</h1>
  1. /*(id,class,tag)
  2. (0, 0 , 0)
  3. 1.实体标记
  4. 2.排列顺序
  5. 3.计数方式
  6. */
  7. /* ? 1.提权修改 */
  8. body p{
  9. color:brown;
  10. }
  11. p{
  12. color:blueviolet;
  13. }
  14. /* ? 2.html修改 */
  15. .al-3.color{
  16. color:yellow;
  17. }
  18. .al-3{
  19. color:blue;
  20. }
  21. .al-3.bgc{
  22. background-color: aqua;
  23. }

实例效果

伪类指定一个实际参数nth-of-type(an+b)

  1. <ul class="list">
  2. <li class="item">item1</li>
  3. <li class="item">item2</li>
  4. <li class="item">item3</li>
  5. <li class="item">item4</li>
  6. <li class="item">item5</li>
  7. <li class="item">item6</li>
  8. <li class="item">item7</li>
  9. <li class="item">item8</li>
  10. </ul>
  1. /* :nth-of-type(an+b)
  2. a:系数 0.1
  3. n:参数 0.1.2.3
  4. b:偏移量 从0开始
  5. */
  6. /* 匹配一个或者一组
  7. a=0匹配一个
  8. a=1匹配一组(正向取值)
  9. a=-1匹配一组(反向向取值)
  10. */
  11. .list > li:nth-of-type(5){
  12. background-color: aqua;
  13. }
  14. /* an+b
  15. 0n+5=5
  16. 1.0*0+5=5
  17. 2.0*1+5=5
  18. ....
  19. */
  20. .list > li:nth-of-type(1){
  21. background-color: bisque;
  22. }
  23. /* an+b
  24. 0n+1=1 */
  25. /* 匹配一组
  26. 1. 1*0+6=6
  27. 2. 1*1+6=7
  28. 3. 1*2+6=8
  29. 4. 1*3+6=9 非法索引 停止计算
  30. */
  31. .list > li:nth-of-type(1n+6){
  32. background-color:red;
  33. }
  34. /* 反向取值 取前面三个
  35. 1. -1*0+3=3
  36. 2. -1*1+3=2
  37. 3. -1*2+3=1 非法索引 停止计算
  38. */
  39. .list > li:nth-of-type(-n+3){
  40. background-color: blueviolet;
  41. }

实例效果

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