buttons.less 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. //
  2. // Buttons
  3. // --------------------------------------------------
  4. // Base styles
  5. // --------------------------------------------------
  6. // Core
  7. .btn {
  8. display: inline-block;
  9. .ie7-inline-block();
  10. padding: 4px 12px;
  11. margin-bottom: 0; // For input.btn
  12. font-size: @baseFontSize;
  13. line-height: @baseLineHeight;
  14. text-align: center;
  15. vertical-align: middle;
  16. cursor: pointer;
  17. .buttonBackground(@btnBackground, @btnBackgroundHighlight, @grayDark, 0 1px 1px rgba(255,255,255,.75));
  18. border: 1px solid @btnBorder;
  19. *border: 0; // Remove the border to prevent IE7's black border on input:focus
  20. border-bottom-color: darken(@btnBorder, 10%);
  21. .border-radius(@baseBorderRadius);
  22. .ie7-restore-left-whitespace(); // Give IE7 some love
  23. .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
  24. // Hover state
  25. &:hover {
  26. color: @grayDark;
  27. text-decoration: none;
  28. background-position: 0 -15px;
  29. // transition is only when going to hover, otherwise the background
  30. // behind the gradient (there for IE<=9 fallback) gets mismatched
  31. .transition(background-position .1s linear);
  32. }
  33. // Focus state for keyboard and accessibility
  34. &:focus {
  35. .tab-focus();
  36. }
  37. // Active state
  38. &.active,
  39. &:active {
  40. background-image: none;
  41. outline: 0;
  42. .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
  43. }
  44. // Disabled state
  45. &.disabled,
  46. &[disabled] {
  47. cursor: default;
  48. background-image: none;
  49. .opacity(65);
  50. .box-shadow(none);
  51. }
  52. }
  53. // Button Sizes
  54. // --------------------------------------------------
  55. // Large
  56. .btn-large {
  57. padding: @paddingLarge;
  58. font-size: @fontSizeLarge;
  59. .border-radius(@borderRadiusLarge);
  60. }
  61. .btn-large [class^="icon-"],
  62. .btn-large [class*=" icon-"] {
  63. margin-top: 4px;
  64. }
  65. // Small
  66. .btn-small {
  67. padding: @paddingSmall;
  68. font-size: @fontSizeSmall;
  69. .border-radius(@borderRadiusSmall);
  70. }
  71. .btn-small [class^="icon-"],
  72. .btn-small [class*=" icon-"] {
  73. margin-top: 0;
  74. }
  75. .btn-mini [class^="icon-"],
  76. .btn-mini [class*=" icon-"] {
  77. margin-top: -1px;
  78. }
  79. // Mini
  80. .btn-mini {
  81. padding: @paddingMini;
  82. font-size: @fontSizeMini;
  83. .border-radius(@borderRadiusSmall);
  84. }
  85. // Block button
  86. // -------------------------
  87. .btn-block {
  88. display: block;
  89. width: 100%;
  90. padding-left: 0;
  91. padding-right: 0;
  92. .box-sizing(border-box);
  93. }
  94. // Vertically space out multiple block buttons
  95. .btn-block + .btn-block {
  96. margin-top: 5px;
  97. }
  98. // Specificity overrides
  99. input[type="submit"],
  100. input[type="reset"],
  101. input[type="button"] {
  102. &.btn-block {
  103. width: 100%;
  104. }
  105. }
  106. // Alternate buttons
  107. // --------------------------------------------------
  108. // Provide *some* extra contrast for those who can get it
  109. .btn-primary.active,
  110. .btn-warning.active,
  111. .btn-danger.active,
  112. .btn-success.active,
  113. .btn-info.active,
  114. .btn-inverse.active {
  115. color: rgba(255,255,255,.75);
  116. }
  117. // Set the backgrounds
  118. // -------------------------
  119. .btn {
  120. // reset here as of 2.0.3 due to Recess property order
  121. border-color: #c5c5c5;
  122. border-color: rgba(0,0,0,.15) rgba(0,0,0,.15) rgba(0,0,0,.25);
  123. }
  124. .btn-primary {
  125. .buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
  126. }
  127. // Warning appears are orange
  128. .btn-warning {
  129. .buttonBackground(@btnWarningBackground, @btnWarningBackgroundHighlight);
  130. }
  131. // Danger and error appear as red
  132. .btn-danger {
  133. .buttonBackground(@btnDangerBackground, @btnDangerBackgroundHighlight);
  134. }
  135. // Success appears as green
  136. .btn-success {
  137. .buttonBackground(@btnSuccessBackground, @btnSuccessBackgroundHighlight);
  138. }
  139. // Info appears as a neutral blue
  140. .btn-info {
  141. .buttonBackground(@btnInfoBackground, @btnInfoBackgroundHighlight);
  142. }
  143. // Inverse appears as dark gray
  144. .btn-inverse {
  145. .buttonBackground(@btnInverseBackground, @btnInverseBackgroundHighlight);
  146. }
  147. // Cross-browser Jank
  148. // --------------------------------------------------
  149. button.btn,
  150. input[type="submit"].btn {
  151. // Firefox 3.6 only I believe
  152. &::-moz-focus-inner {
  153. padding: 0;
  154. border: 0;
  155. }
  156. // IE7 has some default padding on button controls
  157. *padding-top: 3px;
  158. *padding-bottom: 3px;
  159. &.btn-large {
  160. *padding-top: 7px;
  161. *padding-bottom: 7px;
  162. }
  163. &.btn-small {
  164. *padding-top: 3px;
  165. *padding-bottom: 3px;
  166. }
  167. &.btn-mini {
  168. *padding-top: 1px;
  169. *padding-bottom: 1px;
  170. }
  171. }
  172. // Link buttons
  173. // --------------------------------------------------
  174. // Make a button look and behave like a link
  175. .btn-link,
  176. .btn-link:active,
  177. .btn-link[disabled] {
  178. background-color: transparent;
  179. background-image: none;
  180. .box-shadow(none);
  181. }
  182. .btn-link {
  183. border-color: transparent;
  184. cursor: pointer;
  185. color: @linkColor;
  186. .border-radius(0);
  187. }
  188. .btn-link:hover {
  189. color: @linkColorHover;
  190. text-decoration: underline;
  191. background-color: transparent;
  192. }
  193. .btn-link[disabled]:hover {
  194. color: @grayDark;
  195. text-decoration: none;
  196. }