buttons.less 3.7 KB

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