_buttons.scss 3.7 KB

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