20_权重值.html 877 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. /* *通配符选择器0 < 标签选择器1 < 类选择器10 < id选择器100 < (内联样式)行内样式1000 < !important10000 */
  9. /* 权重值是可以累加的 */
  10. /* 10 + 10 = 20 */
  11. /* .box1 .box2 {
  12. color: blue;
  13. } */
  14. /* 10 */
  15. /* .box2 {
  16. color: red;
  17. } */
  18. /* 不允许跨等级对比 比如11类 也不可能超过一个ID */
  19. .box1 .box2{
  20. color: blue !important;
  21. }
  22. .box2{
  23. color: red !important;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div class="box1">
  29. <div class="box2">hello world</div>
  30. </div>
  31. </body>
  32. </html>