11.选择器.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. /* * 通配符选择器 匹配全局 */
  9. * {
  10. list-style: none;
  11. text-decoration: none;
  12. font-size: 40px;
  13. }
  14. /* id选择器 */
  15. /* 类选择器
  16. body:
  17. class='xxx'
  18. style:
  19. .xxx{样式}
  20. */
  21. .box {
  22. width: 200px;
  23. height: 200px;
  24. background: red;
  25. }
  26. /* 标签选择器 */
  27. /* h1 {
  28. color: pink;
  29. } */
  30. /* 包含选择器 / 后代选择器 */
  31. .main span {
  32. color: red;
  33. }
  34. /* 群组选择器 */
  35. /* h2,
  36. h4 {
  37. color: purple;
  38. } */
  39. /* 伪类选择器 */
  40. /* ul li:first-child {
  41. color: red;
  42. }
  43. ul li:last-child {
  44. color: blue;
  45. } */
  46. /*
  47. 偶数:2n even
  48. 奇数:2n+1 odd
  49. */
  50. /* ul li:nth-child(odd) {
  51. color: yellow;
  52. }
  53. ul li:hover {
  54. color: #0f0;
  55. } */
  56. /* 伪元素选择器
  57. ::after :after
  58. */
  59. .news::after {
  60. content: "大家好";
  61. color: #0f0;
  62. }
  63. .news::before {
  64. content: "你好";
  65. color: rgb(115, 0, 255);
  66. }
  67. /* 相邻选择器 + */
  68. /* h3+h4 {
  69. color: rgb(0, 38, 255);
  70. } */
  71. /* 兄弟选择器 ~ */
  72. /* h1~h3 {
  73. color: rgb(0, 38, 255);
  74. }
  75. h1~.hello {
  76. color: rgb(0, 255, 106);
  77. }
  78. h1~.vase {
  79. color: rgb(255, 213, 0);
  80. } */
  81. /* !important */
  82. h1 {
  83. color: red !important;
  84. }
  85. h1 {
  86. color: rgb(0, 255, 119);
  87. }
  88. /* 属性选择器
  89. body:
  90. 属性中添加xxx
  91. style
  92. [属性=xxx]{样式}
  93. */
  94. img[alt='aaa'] {
  95. width: 200px;
  96. height: 200px;
  97. }
  98. </style>
  99. </head>
  100. <body>
  101. <div>
  102. <img src="./images/img01.gif" alt="aaa">
  103. <div class="hi">
  104. <h1>11111</h1>
  105. <h2>22222</h2>
  106. <h3>33333</h3>
  107. <h4>444444</h4>
  108. <h5>5555</h5>
  109. <div class="hello">大家好</div>
  110. <div class="vase">aaaaa</div>
  111. </div>
  112. <ul>
  113. <li><a href="">哈哈哈</a></li>
  114. <li><a href="">哈哈哈</a></li>
  115. <li><a href="">哈哈哈</a></li>
  116. <li><a href="">哈哈哈</a></li>
  117. <li><a href="">哈哈哈</a></li>
  118. <li><a href="">哈哈哈</a></li>
  119. <li><a href="">哈哈哈</a></li>
  120. </ul>
  121. <!-- <div class="news">哈哈哈哈</div>
  122. <ul>
  123. <li>你好</li>
  124. <li>你好</li>
  125. <li>你好</li>
  126. <li>你好</li>
  127. <li>你好</li>
  128. <li>你好</li>
  129. <li>你好</li>
  130. </ul>
  131. <h2>111</h2>
  132. <div class="main">
  133. <span>hello</span>
  134. </div>
  135. <div class="box"></div>
  136. <h1>你好</h1>
  137. <h4>呃呃问问</h4> -->
  138. </div>
  139. </body>
  140. </html>