index.less 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. @import './var.less';
  2. :root {
  3. --van-tab-text-color: @tab-text-color;
  4. --van-tab-active-text-color: @tab-active-text-color;
  5. --van-tab-disabled-text-color: @tab-disabled-text-color;
  6. --van-tab-font-size: @tab-font-size;
  7. --van-tab-line-height: @tab-line-height;
  8. --van-tabs-default-color: @tabs-default-color;
  9. --van-tabs-line-height: @tabs-line-height;
  10. --van-tabs-card-height: @tabs-card-height;
  11. --van-tabs-nav-background-color: @tabs-nav-background-color;
  12. --van-tabs-bottom-bar-width: @tabs-bottom-bar-width;
  13. --van-tabs-bottom-bar-height: @tabs-bottom-bar-height;
  14. --van-tabs-bottom-bar-color: @tabs-bottom-bar-color;
  15. }
  16. .van-tab {
  17. position: relative;
  18. display: flex;
  19. flex: 1;
  20. align-items: center;
  21. justify-content: center;
  22. box-sizing: border-box;
  23. padding: 0 var(--van-padding-base);
  24. color: var(--van-tab-text-color);
  25. font-size: var(--van-tab-font-size);
  26. line-height: var(--van-tab-line-height);
  27. cursor: pointer;
  28. &--active {
  29. color: var(--van-tab-active-text-color);
  30. font-weight: var(--van-font-weight-bold);
  31. }
  32. &--disabled {
  33. color: var(--van-tab-disabled-text-color);
  34. cursor: not-allowed;
  35. }
  36. &--grow {
  37. flex: 1 0 auto;
  38. padding: 0 var(--van-padding-sm);
  39. }
  40. &--shrink {
  41. flex: none;
  42. padding: 0 var(--van-padding-xs);
  43. }
  44. &--card {
  45. color: var(--van-tabs-default-color);
  46. border-right: var(--van-border-width-base) solid
  47. var(--van-tabs-default-color);
  48. &:last-child {
  49. border-right: none;
  50. }
  51. &.van-tab--active {
  52. color: var(--van-white);
  53. background-color: var(--van-tabs-default-color);
  54. }
  55. &--disabled {
  56. color: var(--van-tab-disabled-text-color);
  57. }
  58. }
  59. &__text {
  60. &--ellipsis {
  61. display: -webkit-box;
  62. overflow: hidden;
  63. -webkit-line-clamp: 1;
  64. -webkit-box-orient: vertical;
  65. }
  66. }
  67. }
  68. .van-tabs {
  69. position: relative;
  70. &__wrap {
  71. overflow: hidden;
  72. &--page-top {
  73. position: fixed;
  74. }
  75. &--content-bottom {
  76. top: auto;
  77. bottom: 0;
  78. }
  79. }
  80. &__nav {
  81. position: relative;
  82. display: flex;
  83. background: var(--van-tabs-nav-background-color);
  84. user-select: none;
  85. &--complete {
  86. overflow-x: auto;
  87. overflow-y: hidden;
  88. -webkit-overflow-scrolling: touch;
  89. &::-webkit-scrollbar {
  90. display: none;
  91. }
  92. }
  93. &--line {
  94. box-sizing: content-box;
  95. height: 100%;
  96. padding-bottom: 15px; /* 15px padding to hide scrollbar in mobile safari */
  97. }
  98. &--line&--shrink,
  99. &--line&--complete {
  100. padding-right: var(--van-padding-xs);
  101. padding-left: var(--van-padding-xs);
  102. }
  103. &--card {
  104. box-sizing: border-box;
  105. height: var(--van-tabs-card-height);
  106. margin: 0 var(--van-padding-md);
  107. border: var(--van-border-width-base) solid var(--van-tabs-default-color);
  108. border-radius: var(--van-border-radius-sm);
  109. }
  110. &--card&--shrink {
  111. display: inline-flex;
  112. }
  113. }
  114. &__line {
  115. position: absolute;
  116. bottom: 15px;
  117. left: 0;
  118. z-index: 1;
  119. width: var(--van-tabs-bottom-bar-width);
  120. height: var(--van-tabs-bottom-bar-height);
  121. background: var(--van-tabs-bottom-bar-color);
  122. border-radius: var(--van-tabs-bottom-bar-height);
  123. }
  124. &__track {
  125. position: relative;
  126. display: flex;
  127. width: 100%;
  128. height: 100%;
  129. will-change: left;
  130. }
  131. &__content {
  132. &--animated {
  133. overflow: hidden;
  134. }
  135. }
  136. &--line {
  137. .van-tabs__wrap {
  138. height: var(--van-tabs-line-height);
  139. }
  140. }
  141. &--card {
  142. > .van-tabs__wrap {
  143. height: var(--van-tabs-card-height);
  144. }
  145. }
  146. }