navigationBar.wxss 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* components/navigationBar/navigationBar.wxss */
  2. page {
  3. /* 主要背景色 */
  4. --color: #f2f6f7;
  5. background: var(--color);
  6. /* 导航栏选中项颜色 */
  7. --bg: rgb(255, 255, 255);
  8. --w: 175rpx;
  9. --t: 750rpx;
  10. --c: 120rpx;
  11. /* 注意:env()和constant()需要同时存在,且constant()在前 */
  12. padding-bottom: calc(constant(safe-area-inset-bottom) +140rpx);
  13. padding-bottom: calc(env(safe-area-inset-bottom) + 140rpx);
  14. }
  15. .tabbar-box {
  16. background: #fff;
  17. border-radius: 10rpx 10rpx 0 0;
  18. position: relative;
  19. height: 120rpx;
  20. width: var(--t);
  21. display: flex;
  22. align-items: center;
  23. justify-content: center;
  24. position: fixed;
  25. left: 0;
  26. bottom: 0;
  27. z-index: 10;
  28. padding-bottom: constant(safe-area-inset-bottom);
  29. padding-bottom: env(safe-area-inset-bottom);
  30. }
  31. .menu-item {
  32. display: flex;
  33. align-items: center;
  34. justify-content: center;
  35. flex-direction: column;
  36. width: var(--w);
  37. height: 100%;
  38. -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  39. }
  40. .menu-item .iconfont {
  41. font-size: 40rpx;
  42. color: var(--color);
  43. transition: 0.5s all;
  44. position: relative;
  45. z-index: 9;
  46. }
  47. .menu-item text {
  48. position: absolute;
  49. font-size: 26rpx;
  50. font-weight: bold;
  51. color: #222;
  52. transition: 0.5s all;
  53. opacity: 0;
  54. transform: translateY(50rpx);
  55. }
  56. .menu-item.active .iconfont {
  57. transform: translateY(-60rpx);
  58. }
  59. .menu-item.active text {
  60. opacity: 1;
  61. transform: translateY(22rpx);
  62. }
  63. .active-tabbar-box {
  64. box-sizing: border-box;
  65. position: absolute;
  66. width: var(--c);
  67. height: var(--c);
  68. background: var(--bg);
  69. --left-pad: calc(var(--t) - (4 * var(--w)));
  70. left: calc((var(--left-pad) / 2) + (var(--w) / 2) - (var(--c) / 2));
  71. top: calc(-50% + constant(safe-area-inset-bottom) / 2);
  72. top: calc(-50% + env(safe-area-inset-bottom) / 2);
  73. border-radius: 50%;
  74. border: 10rpx solid var(--color);
  75. transition: 0.5s all;
  76. }
  77. .active-tabbar-box::before,
  78. .active-tabbar-box::after {
  79. content: "";
  80. position: absolute;
  81. top: 50%;
  82. width: 30rpx;
  83. height: 30rpx;
  84. background: transparent;
  85. }
  86. .active-tabbar-box::before {
  87. left: -33rpx;
  88. border-radius: 0 30rpx 0 0;
  89. box-shadow: 0 -15rpx 0 0 var(--color);
  90. }
  91. .active-tabbar-box::after {
  92. right: -33rpx;
  93. border-radius: 30rpx 0 0 0;
  94. box-shadow: 0 -15rpx 0 0 var(--color);
  95. }
  96. .active-tabbar-box {
  97. transform: translateX(calc(var(--w) * var(--n)));
  98. }