buttons.less 3.2 KB

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