01-XX-conditional-rule-block.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>The Conditional Rule Block</title>
  6. <style>
  7. body {
  8. font-size: 1.5em;
  9. }
  10. .support-info {
  11. color: #842e98;
  12. }
  13. /**
  14. * Check if a certain declaration is supported, within the parentheses:
  15. */
  16. @supports (display: grid) {
  17. body {
  18. background-color: #333;
  19. }
  20. .support-info {
  21. color: #a6edb2;
  22. }
  23. }
  24. /**
  25. *
  26. * You can also check for combinations of declarations, or use "or" to test
  27. * for either of multiple declarations. You can nest them in parentheses.
  28. * Combinations use "and":
  29. * @supports (display: grid) and (display: inline-grid) { ... }
  30. * Note: this rule is just for demo purposes: it will override the
  31. * previous declaration with a more detailed one – there’s no practical benefit
  32. * in combining them.
  33. */
  34. @supports ((display: grid) or (display: -webkit-grid)) and
  35. ((display: inline-grid) or (display: -webkit-inline-grid)) {
  36. body {
  37. background-color: #333;
  38. color: #fff;
  39. }
  40. .support-info {
  41. color: #a6edb2;
  42. }
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <p class="support-info">If this is purple, your browser does not support Grid Layout. If this is light green on dark gray, it does!</p>
  48. <p><small>(If it’s neither, you may have turned off CSS styling!)</small></p>
  49. </body>
  50. </html>