buttons.less 3.4 KB

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