buttons.less 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. .btn-primary-on-primary-bg {
  61. .button-variant(@white; @ol-dark-green; @ol-dark-green);
  62. }
  63. // Success appears as green
  64. .btn-success {
  65. .button-variant(@btn-success-color; @btn-success-bg; @btn-success-border);
  66. }
  67. // Info appears as blue-green
  68. .btn-info {
  69. .button-variant(@btn-info-color; @btn-info-bg; @btn-info-border);
  70. }
  71. // Warning appears as orange
  72. .btn-warning {
  73. .button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
  74. }
  75. // Danger and error appear as red
  76. .btn-danger {
  77. .button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
  78. }
  79. .reset-btns {
  80. // reset all buttons back to their original colors
  81. .btn-danger {
  82. .btn-danger;
  83. }
  84. .btn-default {
  85. .btn-default;
  86. }
  87. .btn-default-outline {
  88. .btn-default-outline;
  89. }
  90. .btn-info {
  91. .btn-info;
  92. }
  93. .btn-primary {
  94. .btn-primary;
  95. }
  96. .btn-success {
  97. .btn-success;
  98. }
  99. .btn-warning {
  100. .btn-warning;
  101. }
  102. }
  103. // Link buttons
  104. // -------------------------
  105. // Make a button look and behave like a link
  106. .btn-link {
  107. color: @link-color;
  108. font-weight: normal;
  109. cursor: pointer;
  110. border-radius: 0;
  111. &,
  112. &:active,
  113. &[disabled],
  114. fieldset[disabled] & {
  115. background-color: transparent;
  116. .box-shadow(none);
  117. }
  118. &,
  119. &:hover,
  120. &:focus,
  121. &:active {
  122. border-color: transparent;
  123. }
  124. &:hover,
  125. &:focus {
  126. color: @link-hover-color;
  127. text-decoration: underline;
  128. background-color: transparent;
  129. }
  130. &[disabled],
  131. fieldset[disabled] & {
  132. &:hover,
  133. &:focus {
  134. color: @btn-link-disabled-color;
  135. text-decoration: none;
  136. }
  137. }
  138. }
  139. .btn-inline-link {
  140. .btn-link();
  141. padding: 0;
  142. font-size: inherit;
  143. vertical-align: inherit;
  144. }
  145. // Button Sizes
  146. // --------------------------------------------------
  147. .btn-xl {
  148. .button-size(
  149. @padding-large-vertical; @padding-large-horizontal; @font-size-h2;
  150. @line-height-large; @btn-border-radius-large
  151. );
  152. }
  153. .btn-lg {
  154. // line-height: ensure even-numbered height of button next to large input
  155. .button-size(
  156. @padding-large-vertical; @padding-large-horizontal; @font-size-large;
  157. @line-height-large; @btn-border-radius-large
  158. );
  159. }
  160. .btn-sm {
  161. // line-height: ensure proper height of button next to small input
  162. .button-size(
  163. @padding-small-vertical; @padding-small-horizontal; @font-size-small;
  164. @line-height-small; @btn-border-radius-small
  165. );
  166. }
  167. .btn-xs {
  168. .button-size(
  169. @padding-xs-vertical; @padding-xs-horizontal; @font-size-small;
  170. @line-height-small; @btn-border-radius-small
  171. );
  172. }
  173. // Block button
  174. // --------------------------------------------------
  175. .btn-block {
  176. display: block;
  177. width: 100%;
  178. padding-left: 0;
  179. padding-right: 0;
  180. }
  181. // Vertically space out multiple block buttons
  182. .btn-block + .btn-block {
  183. margin-top: 5px;
  184. }
  185. // Specificity overrides
  186. input[type='submit'],
  187. input[type='reset'],
  188. input[type='button'] {
  189. &.btn-block {
  190. width: 100%;
  191. }
  192. }