variable.uvue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="page">
  3. <view class="status-bar-height">
  4. <text>status bar height</text>
  5. </view>
  6. <view class="window-top">
  7. <text>window top</text>
  8. </view>
  9. <view class="window-bottom">
  10. <text>window bottom</text>
  11. </view>
  12. <view class="uni-safe-area-inset-top">
  13. <text>height:var(--uni-safe-area-inset-top)</text>
  14. </view>
  15. <view class="uni-safe-area-inset-left">
  16. <text>height:var(--uni-safe-area-inset-left)</text>
  17. </view>
  18. <view class="uni-safe-area-inset-right">
  19. <text>height:var(--uni-safe-area-inset-right)</text>
  20. </view>
  21. <view class="uni-safe-area-inset-bottom">
  22. <text>height:var(--uni-safe-area-inset-bottom)</text>
  23. </view>
  24. <view class="uni-fixed-bottom">
  25. <text>使用var(--uni-safe-area-inset-*)适配safe-area</text>
  26. </view>
  27. </view>
  28. </template>
  29. <style>
  30. .page {
  31. flex: 1;
  32. }
  33. .status-bar-height {
  34. height: var(--status-bar-height);
  35. background-color: red;
  36. }
  37. .window-top {
  38. height: var(--window-top);
  39. background-color: green;
  40. }
  41. .window-bottom {
  42. height: var(--window-bottom);
  43. background-color: blue;
  44. }
  45. .uni-safe-area-inset-top {
  46. height: var(--uni-safe-area-inset-top);
  47. background-color: yellow;
  48. }
  49. .uni-safe-area-inset-left {
  50. height: var(--uni-safe-area-inset-left);
  51. background-color: greenyellow;
  52. }
  53. .uni-safe-area-inset-right {
  54. height: var(--uni-safe-area-inset-right, 60px);
  55. background-color: saddlebrown;
  56. }
  57. .uni-fixed-bottom {
  58. position: fixed;
  59. left: var(--uni-safe-area-inset-left);
  60. right: var(--uni-safe-area-inset-right);
  61. bottom: var(--uni-safe-area-inset-bottom);
  62. background-color: salmon;
  63. }
  64. .uni-safe-area-inset-bottom {
  65. height: var(--uni-safe-area-inset-bottom);
  66. background-color: salmon;
  67. }
  68. </style>