_input-group.scss 4.6KB

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