buttons.less 3.5 KB

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