4_媒体查询.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 (min-width:500px)" href="./css/a.css">
  8. <style>
  9. .box{
  10. width: 200px;
  11. height: 200px;
  12. background-color: red;
  13. }
  14. /* @media screen and (min-width:500px){
  15. .box{
  16. width: 400px;
  17. height: 400px;
  18. }
  19. } */
  20. /* @media screen and (max-width:500px) {
  21. .box{
  22. background-color: blue;
  23. }
  24. } */
  25. /* @media screen and (min-width:500px) and (max-width:800px){
  26. .box{
  27. background-color: blue;
  28. }
  29. } */
  30. /* 监听屏幕为横屏时 */
  31. /* @media screen and (orientation: landscape){
  32. .box{
  33. background-color: blue;
  34. }
  35. } */
  36. /* 监听屏幕为竖屏 */
  37. /* @media screen and (orientation: portrait){
  38. .box{
  39. background-color: blue;
  40. }
  41. } */
  42. </style>
  43. </head>
  44. <body>
  45. <div class="box"></div>
  46. </body>
  47. </html>