Blogger Information
Blog 19
fans 0
comment 0
visits 10671
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CSS伪类,状态伪类和结构性伪类
无名小辈
Original
398 people have browsed it

/ 状态伪类:当选择得目标对象状态发生改变后,进行什么样的样式设置 /

  1. .list > li.first{
  2. color: blueviolet;
  3. }
  4. .list > li:nth-of-type(1){
  5. color: brown;
  6. }
  7. .list > li:nth-of-type(5){
  8. color: brown;
  9. }
  10. /*
  11. :nth-of-type(an+b)
  12. 1 a:系数,[0,1,2,3...]
  13. 2 n:参数,[0,1,2,3...]
  14. 3 b:偏移量,从0开始
  15. */
  16. /* 匹配一个 */
  17. /* 0*n+5 */
  18. .list > li:nth-of-type(5){
  19. color: brown;
  20. }
  21. /* 匹配一组 */
  22. .list > li:nth-of-type(1n+3){
  23. background-color: blueviolet;
  24. }
  25. .list > li:nth-of-type(-1n+3){
  26. background-color: blue;
  27. }
  28. .list > li:nth-of-type(2n){
  29. background-color: green;
  30. }
  31. /* 前3个 */
  32. .list > li:nth-of-type(-n+3){
  33. background-color: aquamarine;
  34. }
  35. /* 后3个 */
  36. .list > li:nth-last-of-type(-n+3){
  37. background-color: antiquewhite;
  38. }
  39. /* 第一个 */
  40. .list > li:first-of-type{
  41. }
  42. /* 最后一个 */
  43. .list > li:last-of-type{
  44. }
  45. /* 奇偶 even:偶数 */
  46. .list > li:nth-of-type(even){
  47. background-color: red;
  48. }
  49. /* 奇偶 odd:偶数 */
  50. .list > li:nth-of-type(odd){
  51. background-color: green;
  52. }
  53. /* 结构性伪类:选择子元素去使用的 */
  54. /* 设置被禁用元素样式 */
  55. input:disabled{
  56. color: blue;
  57. }
  58. button:hover{
  59. background-color: blue;
  60. }
  61. input.a +{
  62. background-color: blue;
  63. }
  64. input:focus{
  65. background-color: blue;
  66. }
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