6_媒体查询.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. <link rel="stylesheet" media="screen and (max-width: 600px)" href="./css/a.css">
  8. <link rel="stylesheet" media="screen and (max-width: 900px) and (min-width: 800px)" href="./css/b.css">
  9. <style>
  10. .box{
  11. width: 200px;
  12. height: 200px;
  13. background-color: red;
  14. }
  15. @media screen and (max-width:500px) {
  16. .box{
  17. background-color: blue;
  18. }
  19. }
  20. @media screen and (max-width:600px) and (min-width:500px) {
  21. .box{
  22. background-color: yellow;
  23. }
  24. }
  25. /* 竖屏 */
  26. @media (orientation:portrait){
  27. .box{
  28. font-size: 50px;
  29. color: aqua;
  30. }
  31. }
  32. /* 横屏 */
  33. @media (orientation:landscape){
  34. .box{
  35. font-size: 60px;
  36. color: blueviolet;
  37. }
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <a href="https://www.runoob.com/cssref/css3-pr-mediaquery.html">文档</a>
  43. <div class="box">hello</div>
  44. </body>
  45. </html>