index.less 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. @import '../common/style/var.less';
  2. @import '../common/style/theme.less';
  3. .van-button {
  4. position: relative;
  5. display: inline-flex;
  6. align-items: center;
  7. justify-content: center;
  8. box-sizing: border-box;
  9. padding: 0;
  10. text-align: center;
  11. vertical-align: middle;
  12. -webkit-appearance: none;
  13. -webkit-text-size-adjust: 100%;
  14. .theme(height, '@button-default-height');
  15. .theme(line-height, '@button-line-height');
  16. .theme(font-size, '@button-default-font-size');
  17. .theme(transition, 'opacity @animation-duration-fast');
  18. .theme(border-radius, '@button-border-radius');
  19. &::before {
  20. position: absolute;
  21. top: 50%;
  22. left: 50%;
  23. width: 100%;
  24. height: 100%;
  25. border: inherit;
  26. border-radius: inherit; /* inherit parent's border radius */
  27. transform: translate(-50%, -50%);
  28. opacity: 0;
  29. content: ' ';
  30. .theme(background-color, '@black');
  31. .theme(border-color, '@black');
  32. }
  33. // reset weapp default border
  34. &::after {
  35. border-width: 0;
  36. }
  37. &--active::before {
  38. opacity: 0.15;
  39. }
  40. &--unclickable::after {
  41. display: none;
  42. }
  43. &--default {
  44. .theme(color, '@button-default-color');
  45. .theme(background, '@button-default-background-color');
  46. .theme(border, '@button-border-width solid @button-default-border-color');
  47. }
  48. &--primary {
  49. .theme(color, '@button-primary-color');
  50. .theme(background, '@button-primary-background-color');
  51. .theme(border, '@button-border-width solid @button-primary-border-color');
  52. }
  53. &--info {
  54. .theme(color, '@button-info-color');
  55. .theme(background, '@button-info-background-color');
  56. .theme(border, '@button-border-width solid @button-info-border-color');
  57. }
  58. &--danger {
  59. .theme(color, '@button-danger-color');
  60. .theme(background, '@button-danger-background-color');
  61. .theme(border, '@button-border-width solid @button-danger-border-color');
  62. }
  63. &--warning {
  64. .theme(color, '@button-warning-color');
  65. .theme(background, '@button-warning-background-color');
  66. .theme(border, '@button-border-width solid @button-warning-border-color');
  67. }
  68. &--plain {
  69. .theme(background, '@button-plain-background-color');
  70. &.van-button--primary {
  71. .theme(color, '@button-primary-background-color');
  72. }
  73. &.van-button--info {
  74. .theme(color, '@button-info-background-color');
  75. }
  76. &.van-button--danger {
  77. .theme(color, '@button-danger-background-color');
  78. }
  79. &.van-button--warning {
  80. .theme(color, '@button-warning-background-color');
  81. }
  82. }
  83. &--large {
  84. width: 100%;
  85. .theme(height, '@button-large-height');
  86. }
  87. &--normal {
  88. padding: 0 15px;
  89. .theme(font-size, '@button-normal-font-size');
  90. }
  91. &--small {
  92. .theme(min-width, '@button-small-min-width');
  93. .theme(height, '@button-small-height');
  94. .theme(padding, '0 @padding-xs');
  95. .theme(font-size, '@button-small-font-size');
  96. }
  97. // mini图标默认宽度50px,文字不能超过4个
  98. &--mini {
  99. display: inline-block;
  100. .theme(min-width, '@button-mini-min-width');
  101. .theme(height, '@button-mini-height');
  102. .theme(font-size, '@button-mini-font-size');
  103. & + .van-button--mini {
  104. margin-left: 5px;
  105. }
  106. }
  107. &--block {
  108. display: flex;
  109. width: 100%;
  110. }
  111. &--round {
  112. .theme(border-radius, '@button-round-border-radius');
  113. }
  114. &--square {
  115. border-radius: 0;
  116. }
  117. &--disabled {
  118. .theme(opacity, '@button-disabled-opacity');
  119. }
  120. &__text {
  121. display: inline;
  122. }
  123. &__loading-text,
  124. &__icon + &__text:not(:empty) {
  125. margin-left: @padding-base;
  126. }
  127. &__icon {
  128. min-width: 1em;
  129. line-height: inherit !important;
  130. vertical-align: top;
  131. }
  132. &--hairline {
  133. padding-top: 1px; // add 1px padding for text vertical align middle
  134. border-width: 0;
  135. &::after {
  136. border-color: inherit;
  137. border-width: 1px;
  138. .theme(border-radius, 'calc(@button-border-radius * 2)');
  139. }
  140. &.van-button--round::after {
  141. .theme(border-radius, '@button-round-border-radius');
  142. }
  143. &.van-button--square::after {
  144. border-radius: 0;
  145. }
  146. }
  147. }