buttons.less 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. //
  2. // Buttons
  3. // --------------------------------------------------
  4. // Base styles
  5. // --------------------------------------------------
  6. .btn {
  7. display: inline-block;
  8. margin-bottom: 0; // For input.btn
  9. font-weight: @btn-font-weight;
  10. text-align: center;
  11. vertical-align: middle;
  12. cursor: pointer;
  13. background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  14. border: @btn-border-width solid transparent;
  15. border-bottom: @btn-border-bottom-width solid transparent;
  16. white-space: nowrap;
  17. .button-size(
  18. @padding-base-vertical; @padding-base-horizontal; @font-size-base;
  19. @line-height-base; @btn-border-radius-base
  20. );
  21. .user-select(none);
  22. &,
  23. &:active,
  24. &.active {
  25. &:focus {
  26. .tab-focus();
  27. }
  28. }
  29. &:hover,
  30. &:focus {
  31. color: @btn-default-color;
  32. text-decoration: none;
  33. }
  34. &:active,
  35. &.active {
  36. outline: 0;
  37. background-image: none;
  38. .box-shadow(inset 0 3px 5px rgba(0, 0, 0, 0.125));
  39. }
  40. &.disabled,
  41. &[disabled],
  42. fieldset[disabled] & {
  43. cursor: not-allowed;
  44. pointer-events: none; // Future-proof disabling of clicks
  45. .opacity(0.65);
  46. .box-shadow(none);
  47. }
  48. }
  49. // Alternate buttons
  50. // --------------------------------------------------
  51. .btn-default {
  52. .button-variant(@btn-default-color; @btn-default-bg; @btn-default-border);
  53. }
  54. .btn-default-outline {
  55. .button-outline-variant(@btn-default-bg);
  56. }
  57. .btn-primary {
  58. .button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border);
  59. }
  60. // Success appears as green
  61. .btn-success {
  62. .button-variant(@btn-success-color; @btn-success-bg; @btn-success-border);
  63. }
  64. // Info appears as blue-green
  65. .btn-info {
  66. .button-variant(@btn-info-color; @btn-info-bg; @btn-info-border);
  67. }
  68. // Warning appears as orange
  69. .btn-warning {
  70. .button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
  71. }
  72. // Danger and error appear as red
  73. .btn-danger {
  74. .button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
  75. }
  76. // Link buttons
  77. // -------------------------
  78. // Make a button look and behave like a link
  79. .btn-link {
  80. color: @link-color;
  81. font-weight: normal;
  82. cursor: pointer;
  83. border-radius: 0;
  84. &,
  85. &:active,
  86. &[disabled],
  87. fieldset[disabled] & {
  88. background-color: transparent;
  89. .box-shadow(none);
  90. }
  91. &,
  92. &:hover,
  93. &:focus,
  94. &:active {
  95. border-color: transparent;
  96. }
  97. &:hover,
  98. &:focus {
  99. color: @link-hover-color;
  100. text-decoration: underline;
  101. background-color: transparent;
  102. }
  103. &[disabled],
  104. fieldset[disabled] & {
  105. &:hover,
  106. &:focus {
  107. color: @btn-link-disabled-color;
  108. text-decoration: none;
  109. }
  110. }
  111. }
  112. .btn-inline-link {
  113. .btn-link();
  114. padding: 0;
  115. font-size: inherit;
  116. vertical-align: inherit;
  117. }
  118. // Button Sizes
  119. // --------------------------------------------------
  120. .btn-xl {
  121. .button-size(
  122. @padding-large-vertical; @padding-large-horizontal; @font-size-h2;
  123. @line-height-large; @btn-border-radius-large
  124. );
  125. }
  126. .btn-lg {
  127. // line-height: ensure even-numbered height of button next to large input
  128. .button-size(
  129. @padding-large-vertical; @padding-large-horizontal; @font-size-large;
  130. @line-height-large; @btn-border-radius-large
  131. );
  132. }
  133. .btn-sm {
  134. // line-height: ensure proper height of button next to small input
  135. .button-size(
  136. @padding-small-vertical; @padding-small-horizontal; @font-size-small;
  137. @line-height-small; @btn-border-radius-small
  138. );
  139. }
  140. .btn-xs {
  141. .button-size(
  142. @padding-xs-vertical; @padding-xs-horizontal; @font-size-small;
  143. @line-height-small; @btn-border-radius-small
  144. );
  145. }
  146. // Block button
  147. // --------------------------------------------------
  148. .btn-block {
  149. display: block;
  150. width: 100%;
  151. padding-left: 0;
  152. padding-right: 0;
  153. }
  154. // Vertically space out multiple block buttons
  155. .btn-block + .btn-block {
  156. margin-top: 5px;
  157. }
  158. // Specificity overrides
  159. input[type='submit'],
  160. input[type='reset'],
  161. input[type='button'] {
  162. &.btn-block {
  163. width: 100%;
  164. }
  165. }