match-media.uvue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="container">
  3. <view class="section">
  4. <text class="subtitle">基础条件匹配</text>
  5. <match-media min-width="400">
  6. <view class="demo-box">屏幕宽度 ≥ 400px 时显示</view>
  7. </match-media>
  8. <match-media max-width="600">
  9. <view class="demo-box">屏幕宽度 ≤ 600px 时显示</view>
  10. </match-media>
  11. <match-media width="375">
  12. <view class="demo-box">屏幕宽度 = 375px 时显示</view>
  13. </match-media>
  14. <match-media min-height="600">
  15. <view class="demo-box">屏幕高度 ≥ 600px 时显示</view>
  16. </match-media>
  17. <match-media max-height="800">
  18. <view class="demo-box">屏幕高度 ≤ 800px 时显示</view>
  19. </match-media>
  20. <match-media height="667">
  21. <view class="demo-box">屏幕高度 = 667px 时显示</view>
  22. </match-media>
  23. <match-media orientation="portrait">
  24. <view class="demo-box">竖屏 时显示</view>
  25. </match-media>
  26. <match-media orientation="landscape">
  27. <view class="demo-box">横屏 时显示</view>
  28. </match-media>
  29. </view>
  30. <view class="section">
  31. <text class="subtitle">组合条件匹配</text>
  32. <match-media min-width="500" max-width="1000" orientation="landscape">
  33. <view class="demo-box">横屏 且宽度在 500px ~ 1000px 时显示</view>
  34. </match-media>
  35. <match-media min-height="200" max-height="800" orientation="portrait">
  36. <view class="demo-box">竖屏 且高度在 200px ~ 800px 时显示</view>
  37. </match-media>
  38. <match-media min-width="300" max-width="900" min-height="400" max-height="800" orientation="portrait">
  39. <view class="demo-box">竖屏 且宽度在 300px ~ 900px,高度在 400px ~ 800px 时显示</view>
  40. </match-media>
  41. </view>
  42. </view>
  43. </template>
  44. <style>
  45. .container {
  46. padding: 20px;
  47. }
  48. .section {
  49. padding-top: 5px;
  50. }
  51. .subtitle {
  52. font-size: 20px;
  53. font-weight: bold;
  54. margin-bottom: 5px;
  55. }
  56. .demo-box {
  57. padding: 5px 0;
  58. }
  59. </style>