input-groups.less 4.1 KB

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