buttons.less 3.4 KB

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