_input-group.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. //
  2. // Base styles
  3. //
  4. .input-group {
  5. position: relative;
  6. width: 100%;
  7. @if $enable-flex {
  8. display: flex;
  9. } @else {
  10. display: table;
  11. // Prevent input groups from inheriting border styles from table cells when
  12. // placed within a table.
  13. border-collapse: separate;
  14. }
  15. .form-control {
  16. // Ensure that the input is always above the *appended* addon button for
  17. // proper border colors.
  18. position: relative;
  19. z-index: 2;
  20. // Bring the "active" form control to the front
  21. @include hover-focus-active {
  22. z-index: 3;
  23. }
  24. @if $enable-flex {
  25. flex: 1;
  26. } @else {
  27. // IE9 fubars the placeholder attribute in text inputs and the arrows on
  28. // select elements in input groups. To fix it, we float the input. Details:
  29. // https://github.com/twbs/bootstrap/issues/11561#issuecomment-28936855
  30. float: left;
  31. width: 100%;
  32. }
  33. margin-bottom: 0;
  34. }
  35. }
  36. .input-group-addon,
  37. .input-group-btn,
  38. .input-group .form-control {
  39. @if not $enable-flex {
  40. display: table-cell;
  41. }
  42. &:not(:first-child):not(:last-child) {
  43. @include border-radius(0);
  44. }
  45. }
  46. .input-group-addon,
  47. .input-group-btn {
  48. @if not $enable-flex {
  49. width: 1%;
  50. }
  51. white-space: nowrap;
  52. vertical-align: middle; // Match the inputs
  53. }
  54. // Sizing options
  55. //
  56. // Remix the default form control sizing classes into new ones for easier
  57. // manipulation.
  58. .input-group-lg > .form-control,
  59. .input-group-lg > .input-group-addon,
  60. .input-group-lg > .input-group-btn > .btn {
  61. @extend .form-control-lg;
  62. }
  63. .input-group-sm > .form-control,
  64. .input-group-sm > .input-group-addon,
  65. .input-group-sm > .input-group-btn > .btn {
  66. @extend .form-control-sm;
  67. }
  68. //
  69. // Text input groups
  70. //
  71. .input-group-addon {
  72. padding: $input-padding-y $input-padding-x;
  73. margin-bottom: 0; // Allow use of <label> elements by overriding our default margin-bottom
  74. font-size: $font-size-base;
  75. font-weight: normal;
  76. line-height: $input-line-height;
  77. color: $input-color;
  78. text-align: center;
  79. background-color: $input-group-addon-bg;
  80. border: $input-btn-border-width solid $input-group-addon-border-color;
  81. @include border-radius($input-border-radius);
  82. // Sizing
  83. &.form-control-sm {
  84. padding: $input-padding-y-sm $input-padding-x-sm;
  85. font-size: $font-size-sm;
  86. @include border-radius($input-border-radius-sm);
  87. }
  88. &.form-control-lg {
  89. padding: $input-padding-y-lg $input-padding-x-lg;
  90. font-size: $font-size-lg;
  91. @include border-radius($input-border-radius-lg);
  92. }
  93. // scss-lint:disable QualifyingElement
  94. // Nuke default margins from checkboxes and radios to vertically center within.
  95. input[type="radio"],
  96. input[type="checkbox"] {
  97. margin-top: 0;
  98. }
  99. // scss-lint:enable QualifyingElement
  100. }
  101. //
  102. // Reset rounded corners
  103. //
  104. .input-group .form-control:not(:last-child),
  105. .input-group-addon:not(:last-child),
  106. .input-group-btn:not(:last-child) > .btn,
  107. .input-group-btn:not(:last-child) > .btn-group > .btn,
  108. .input-group-btn:not(:last-child) > .dropdown-toggle,
  109. .input-group-btn:not(:first-child) > .btn:not(:last-child):not(.dropdown-toggle),
  110. .input-group-btn:not(:first-child) > .btn-group:not(:last-child) > .btn {
  111. @include border-right-radius(0);
  112. }
  113. .input-group-addon:not(:last-child) {
  114. border-right: 0;
  115. }
  116. .input-group .form-control:not(:first-child),
  117. .input-group-addon:not(:first-child),
  118. .input-group-btn:not(:first-child) > .btn,
  119. .input-group-btn:not(:first-child) > .btn-group > .btn,
  120. .input-group-btn:not(:first-child) > .dropdown-toggle,
  121. .input-group-btn:not(:last-child) > .btn:not(:first-child),
  122. .input-group-btn:not(:last-child) > .btn-group:not(:first-child) > .btn {
  123. @include border-left-radius(0);
  124. }
  125. .form-control + .input-group-addon:not(:first-child) {
  126. border-left: 0;
  127. }
  128. //
  129. // Button input groups
  130. //
  131. .input-group-btn {
  132. position: relative;
  133. // Jankily prevent input button groups from wrapping with `white-space` and
  134. // `font-size` in combination with `inline-block` on buttons.
  135. font-size: 0;
  136. white-space: nowrap;
  137. // Negative margin for spacing, position for bringing hovered/focused/actived
  138. // element above the siblings.
  139. > .btn {
  140. position: relative;
  141. + .btn {
  142. margin-left: (-$input-btn-border-width);
  143. }
  144. // Bring the "active" button to the front
  145. @include hover-focus-active {
  146. z-index: 3;
  147. }
  148. }
  149. // Negative margin to only have a single, shared border between the two
  150. &:not(:last-child) {
  151. > .btn,
  152. > .btn-group {
  153. margin-right: (-$input-btn-border-width);
  154. }
  155. }
  156. &:not(:first-child) {
  157. > .btn,
  158. > .btn-group {
  159. z-index: 2;
  160. margin-left: (-$input-btn-border-width);
  161. // Because specificity
  162. @include hover-focus-active {
  163. z-index: 3;
  164. }
  165. }
  166. }
  167. }