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