2_选择器.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /* div 后面的第一个p标签 */
  10. /* div + p{
  11. background: red;
  12. } */
  13. /* div 后面所有的p标签 */
  14. /* div ~ p{
  15. background: red;
  16. } */
  17. /* li带有class的标签 */
  18. /* li[class] {
  19. background: red;
  20. } */
  21. /* li[class='a']{
  22. background: red;
  23. } */
  24. /* 只包含a */
  25. /* li[class~='a']{
  26. background: red;
  27. } */
  28. /* 首字母为a */
  29. /* li[class^='a']{
  30. background: red;
  31. } */
  32. /* 包含a */
  33. /* li[class*='a']{
  34. background: red;
  35. } */
  36. /* 结尾为b */
  37. /* li[class$='b']{
  38. background: #000;
  39. } */
  40. /* li:last-child{
  41. background: red;
  42. }
  43. */
  44. /* li:nth-child(4){
  45. background: red;
  46. } */
  47. /* li:nth-child(even){
  48. background: red;
  49. }
  50. li:nth-child(odd){
  51. background: pink;
  52. } */
  53. #div1::after{
  54. content: 'xixixi';
  55. background: pink;
  56. }
  57. #div1::before{
  58. content: 'hhehehehehhee';
  59. background: green;
  60. }
  61. </style>
  62. </head>
  63. <body>
  64. <!--
  65. id选择符
  66. 元素选择符
  67. class选择符
  68. 关系选择符
  69. 属性选择符
  70. 伪类选择符
  71. 伪对象选择符
  72. -->
  73. <p>0000000000</p>
  74. <div>1111111111</div>
  75. <p>22222222222</p>
  76. <p>3333333333</p>
  77. <p>44444444444</p>
  78. <ul>
  79. <li class="aa">11111</li>
  80. <li class="a">22222</li>
  81. <li class="ab">33333</li>
  82. <li class="aa">44444</li>
  83. <li class="b">555555</li>
  84. <li class="ba">666666</li>
  85. </ul>
  86. <div id="div1">hahhahhhah</div>
  87. <p>xxxxxx</p>
  88. </body>
  89. </html>