buttons.less 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // BUTTON STYLES
  2. // -------------
  3. // Base styles
  4. // --------------------------------------------------
  5. // Core
  6. .btn {
  7. display: inline-block;
  8. padding: 4px 10px 4px;
  9. margin-bottom: 0; // For input.btn
  10. font-size: @baseFontSize;
  11. line-height: @baseLineHeight;
  12. color: @grayDark;
  13. text-align: center;
  14. text-shadow: 0 1px 1px rgba(255,255,255,.75);
  15. vertical-align: middle;
  16. #gradient > .vertical-three-colors(@white, @white, 25%, darken(@white, 10%)); // Don't use .gradientbar() here since it does a three-color gradient
  17. border: 1px solid #ccc;
  18. border-bottom-color: #bbb;
  19. .border-radius(4px);
  20. @shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
  21. .box-shadow(@shadow);
  22. cursor: pointer;
  23. // Give IE7 some love
  24. .ie7-restore-left-whitespace();
  25. }
  26. // Hover state
  27. .btn:hover {
  28. color: @grayDark;
  29. text-decoration: none;
  30. background-color: darken(@white, 10%);
  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. .btn:focus {
  38. .tab-focus();
  39. }
  40. // Active state
  41. .btn.active,
  42. .btn:active {
  43. background-image: none;
  44. @shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
  45. .box-shadow(@shadow);
  46. background-color: darken(@white, 10%);
  47. background-color: darken(@white, 15%) e("\9");
  48. color: rgba(0,0,0,.5);
  49. outline: 0;
  50. }
  51. // Disabled state
  52. .btn.disabled,
  53. .btn[disabled] {
  54. cursor: default;
  55. background-image: none;
  56. background-color: darken(@white, 10%);
  57. .opacity(65);
  58. .box-shadow(none);
  59. }
  60. // Button Sizes
  61. // --------------------------------------------------
  62. // Large
  63. .btn-large {
  64. padding: 9px 14px;
  65. font-size: @baseFontSize + 2px;
  66. line-height: normal;
  67. .border-radius(5px);
  68. }
  69. .btn-large [class^="icon-"] {
  70. margin-top: 1px;
  71. }
  72. // Small
  73. .btn-small {
  74. padding: 5px 9px;
  75. font-size: @baseFontSize - 2px;
  76. line-height: @baseLineHeight - 2px;
  77. }
  78. .btn-small [class^="icon-"] {
  79. margin-top: -1px;
  80. }
  81. // Alternate buttons
  82. // --------------------------------------------------
  83. // Set text color
  84. // -------------------------
  85. .btn-primary,
  86. .btn-primary:hover,
  87. .btn-warning,
  88. .btn-warning:hover,
  89. .btn-danger,
  90. .btn-danger:hover,
  91. .btn-success,
  92. .btn-success:hover,
  93. .btn-info,
  94. .btn-info:hover {
  95. text-shadow: 0 -1px 0 rgba(0,0,0,.25);
  96. color: @white;
  97. }
  98. // Provide *some* extra contrast for those who can get it
  99. .btn-primary.active,
  100. .btn-warning.active,
  101. .btn-danger.active,
  102. .btn-success.active,
  103. .btn-info.active {
  104. color: rgba(255,255,255,.75);
  105. }
  106. // Set the backgrounds
  107. // -------------------------
  108. .btn-primary {
  109. .buttonBackground(@primaryButtonBackground, spin(@primaryButtonBackground, 20));
  110. }
  111. // Warning appears are orange
  112. .btn-warning {
  113. .buttonBackground(lighten(@orange, 15%), @orange);
  114. }
  115. // Danger and error appear as red
  116. .btn-danger {
  117. .buttonBackground(#ee5f5b, #bd362f);
  118. }
  119. // Success appears as green
  120. .btn-success {
  121. .buttonBackground(#62c462, #51a351);
  122. }
  123. // Info appears as a neutral blue
  124. .btn-info {
  125. .buttonBackground(#5bc0de, #2f96b4);
  126. }
  127. // Cross-browser Jank
  128. // --------------------------------------------------
  129. button.btn,
  130. input[type="submit"].btn {
  131. &::-moz-focus-inner {
  132. padding: 0;
  133. border: 0;
  134. }
  135. // IE7 has some default padding on button controls
  136. *padding-top: 2px;
  137. *padding-bottom: 2px;
  138. &.large {
  139. *padding-top: 7px;
  140. *padding-bottom: 7px;
  141. }
  142. &.small {
  143. *padding-top: 3px;
  144. *padding-bottom: 3px;
  145. }
  146. }