Blogger Information
Blog 56
fans 0
comment 4
visits 38120
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CSS:选择器:伪类-复习(first-of-type,nth-last-of-type,nth-of-type(2n + 1):hover)
异乡客
Original
610 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="en">
  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>选择器:伪类</title>
  8. </head>
  9. <body>
  10. <!--
  11. 伪类:
  12. 1.结构伪类:根据元素位置获取元素
  13. 2.状态伪类:根据状态来获取元素 -->
  14. <ul class="list">
  15. <li class="first">item1</li>
  16. <li>item2</li>
  17. <li>item3</li>
  18. <li>item4</li>
  19. <li>item5</li>
  20. <li>item6</li>
  21. <li>item7</li>
  22. <li>item8</li>
  23. </ul>
  24. <style>
  25. /* .list >:first-child{
  26. background-color: red;
  27. } */
  28. /* .list >p:first-of-type{
  29. background-color: yellow;
  30. }
  31. .list .first{
  32. background-color: lightgreen;
  33. } */
  34. /* .list >li:nth-of-type(3){
  35. background-color: lightblue;
  36. } */
  37. /* .list >li:nth-last-of-type(3){
  38. background-color: lightblue;
  39. } */
  40. .list > :nth-of-type(2n){
  41. background-color: lightblue;
  42. }
  43. .list > :nth-of-type(2n + 1){
  44. background-color: red;
  45. }
  46. .list > :nth-of-type(2n + 1):hover{
  47. background-color: white;
  48. }
  49. </style>
  50. </body>
  51. </html>
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