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. cursor: pointer;
  13. background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  14. border: 1px solid transparent;
  15. border-bottom: 2px 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. .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-primary {
  52. .button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border);
  53. }
  54. // Success appears as green
  55. .btn-success {
  56. .button-variant(@btn-success-color; @btn-success-bg; @btn-success-border);
  57. }
  58. // Info appears as blue-green
  59. .btn-info {
  60. .button-variant(@btn-info-color; @btn-info-bg; @btn-info-border);
  61. }
  62. // Warning appears as orange
  63. .btn-warning {
  64. .button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
  65. }
  66. // Danger and error appear as red
  67. .btn-danger {
  68. .button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
  69. }
  70. // Link buttons
  71. // -------------------------
  72. // Make a button look and behave like a link
  73. .btn-link {
  74. color: @link-color;
  75. font-weight: normal;
  76. cursor: pointer;
  77. border-radius: 0;
  78. &,
  79. &:active,
  80. &[disabled],
  81. fieldset[disabled] & {
  82. background-color: transparent;
  83. .box-shadow(none);
  84. }
  85. &,
  86. &:hover,
  87. &:focus,
  88. &:active {
  89. border-color: transparent;
  90. }
  91. &:hover,
  92. &:focus {
  93. color: @link-hover-color;
  94. text-decoration: underline;
  95. background-color: transparent;
  96. }
  97. &[disabled],
  98. fieldset[disabled] & {
  99. &:hover,
  100. &:focus {
  101. color: @btn-link-disabled-color;
  102. text-decoration: none;
  103. }
  104. }
  105. }
  106. // Button Sizes
  107. // --------------------------------------------------
  108. .btn-lg {
  109. // line-height: ensure even-numbered height of button next to large input
  110. .button-size(@padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large);
  111. }
  112. .btn-sm {
  113. // line-height: ensure proper height of button next to small input
  114. .button-size(@padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
  115. }
  116. .btn-xs {
  117. .button-size(@padding-xs-vertical; @padding-xs-horizontal; @font-size-small; @line-height-small; @border-radius-small);
  118. }
  119. // Block button
  120. // --------------------------------------------------
  121. .btn-block {
  122. display: block;
  123. width: 100%;
  124. padding-left: 0;
  125. padding-right: 0;
  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. }