buttons.less 4.9 KB

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