2_选择器.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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>Document</title>
  8. <style>
  9. *{
  10. margin: 0;
  11. padding: 0;
  12. }
  13. /* 关系选择符 */
  14. /* div + p {
  15. background: red;
  16. } */
  17. /* div ~ p {
  18. background: red;
  19. } */
  20. /* 属性选择器 */
  21. /* li[class]{
  22. background: red;
  23. } */
  24. /* li[class='aaa']{
  25. background: red;
  26. } */
  27. /* li[class~='a']{
  28. background: red;
  29. } */
  30. /* 以a为首个字母 */
  31. /* li[class^='a']{
  32. background: red;
  33. } */
  34. /* li[class*='a']{
  35. background: red;
  36. } */
  37. /* li[class$='b']{
  38. background: red;
  39. } */
  40. /* li:last-child{
  41. background: red;
  42. } */
  43. /* li:nth-child(4){
  44. background: red;
  45. } */
  46. /* li:nth-child(even){
  47. background: red;
  48. } */
  49. /* li:nth-child(odd){
  50. background: orange;
  51. } */
  52. #div1::after {
  53. content: 'xixixi';
  54. background: pink;
  55. }
  56. #div1::before{
  57. content: 'hahahhah';
  58. background: green;
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <!--
  64. id选择器
  65. class选择器
  66. 元素选择器
  67. 关系选择器
  68. 属性选择器
  69. 伪类选择器
  70. -->
  71. <p>000000000</p>
  72. <div>111111111</div>
  73. <div>xxxxxxxx</div>
  74. <p>2222222222</p>
  75. <p>3333333333</p>
  76. <p>4444444444</p>
  77. <br>
  78. <ul>
  79. <li class="aabb">11111</li>
  80. <li>22222</li>
  81. <li class="ba">33333</li>
  82. <li>44444</li>
  83. <li class="aaa">55555</li>
  84. <li class="bbb">66666</li>
  85. <li class="ab">777777</li>
  86. <li>8888</li>
  87. <li class="a">999999</li>
  88. <li class=" a b">00000</li>
  89. <div id="div1">哈哈哈哈哈哈哈哈哈</div>
  90. </ul>
  91. </body>
  92. </html>