select2-bootstrap.scss 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. /*! Select2 Bootstrap 3 CSS v1.4.6 | MIT License | github.com/t0m/select2-bootstrap-css */
  2. /**
  3. * Reset Bootstrap 3 .form-control styles which - if applied to the
  4. * original <select>-element the Select2-plugin may be run against -
  5. * are copied to the .select2-container.
  6. *
  7. * 1. Overwrite .select2-container's original display:inline-block
  8. * with Bootstrap 3's default for .form-control, display:block;
  9. * courtesy of @juristr (@see https://github.com/fk/select2-bootstrap-css/pull/1)
  10. */
  11. .select2-container.form-control {
  12. background: transparent;
  13. box-shadow: none;
  14. border: none;
  15. display: block; /* 1 */
  16. margin: 0;
  17. padding: 0;
  18. }
  19. /**
  20. * Adjust Select2 inputs to fit Bootstrap 3 default .form-control appearance.
  21. */
  22. @mixin bootstrap-input-defaults {
  23. border-color: $input-border;
  24. border-radius: $input-border-radius;
  25. color: $input-color;
  26. font-family: $font-family-base;
  27. background-color: $input-bg;
  28. @include reset-filter;
  29. @include box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));
  30. }
  31. .select2-container .select2-choices .select2-search-field input,
  32. .select2-container .select2-choice,
  33. .select2-container .select2-choices {
  34. background: none;
  35. padding: 0;
  36. @include bootstrap-input-defaults;
  37. }
  38. .select2-search input {
  39. @include bootstrap-input-defaults;
  40. }
  41. .select2-container .select2-choices .select2-search-field input {
  42. @include box-shadow(none);
  43. }
  44. /**
  45. * Adjust Select2 input heights to match the Bootstrap default.
  46. */
  47. .select2-container .select2-choice {
  48. height: $input-height-base;
  49. line-height: $line-height-base;
  50. }
  51. /**
  52. * Address Multi Select2's height which - depending on how many elements have been selected -
  53. * may grown higher than their initial size.
  54. */
  55. .select2-container.select2-container-multi.form-control {
  56. height: auto;
  57. }
  58. /**
  59. * Address Bootstrap 3 control sizing classes
  60. * @see http://getbootstrap.com/css/#forms-control-sizes
  61. */
  62. .select2-container.input-sm .select2-choice,
  63. .input-group-sm .select2-container .select2-choice {
  64. height: $input-height-small;
  65. line-height: $line-height-small;
  66. border-radius: $border-radius-small;
  67. }
  68. .select2-container.input-lg .select2-choice,
  69. .input-group-lg .select2-container .select2-choice {
  70. height: $input-height-large;
  71. line-height: $line-height-large;
  72. border-radius: $border-radius-large;
  73. }
  74. .select2-container-multi .select2-choices .select2-search-field input {
  75. height: $input-height-base - 2px;
  76. }
  77. .select2-container-multi.input-sm .select2-choices .select2-search-field input,
  78. .input-group-sm .select2-container-multi .select2-choices .select2-search-field input {
  79. height: $input-height-small - 2px;
  80. }
  81. .select2-container-multi.input-lg .select2-choices .select2-search-field input,
  82. .input-group-lg .select2-container-multi .select2-choices .select2-search-field input {
  83. height: $input-height-large - 2px;
  84. }
  85. /**
  86. * Adjust height and line-height for .select2-search-field amd multi-select Select2 widgets.
  87. *
  88. * 1. Class repetition to address missing .select2-chosen in Select2 < 3.3.2.
  89. */
  90. .select2-container-multi .select2-choices .select2-search-field input {
  91. margin: 0;
  92. }
  93. .select2-chosen,
  94. .select2-choice > span:first-child, /* 1 */
  95. .select2-container .select2-choices .select2-search-field input {
  96. padding: $padding-base-vertical $padding-base-horizontal;
  97. }
  98. .input-sm .select2-chosen,
  99. .input-group-sm .select2-chosen,
  100. .input-sm .select2-choice > span:first-child, /* 1 */
  101. .input-group-sm .select2-choice > span:first-child, /* 1 */
  102. .input-sm .select2-choices .select2-search-field input,
  103. .input-group-sm .select2-choices .select2-search-field input {
  104. padding: $padding-small-vertical $padding-small-horizontal;
  105. }
  106. .input-lg .select2-chosen,
  107. .input-group-lg .select2-chosen,
  108. .input-lg .select2-choice > span:first-child, /* 1 */
  109. .input-group-lg .select2-choice > span:first-child, /* 1 */
  110. .input-lg .select2-choices .select2-search-field input,
  111. .input-group-lg .select2-choices .select2-search-field input {
  112. padding: $padding-large-vertical $padding-large-horizontal;
  113. }
  114. .select2-container-multi .select2-choices .select2-search-choice {
  115. margin-top: 5px;
  116. margin-bottom: 3px;
  117. }
  118. .select2-container-multi.input-sm .select2-choices .select2-search-choice,
  119. .input-group-sm .select2-container-multi .select2-choices .select2-search-choice {
  120. margin-top: 3px;
  121. margin-bottom: 2px;
  122. }
  123. .select2-container-multi.input-lg .select2-choices .select2-search-choice,
  124. .input-group-lg .select2-container-multi .select2-choices .select2-search-choice {
  125. line-height: 24px;
  126. }
  127. /**
  128. * Adjust the single Select2's dropdown arrow button appearance.
  129. *
  130. * 1. For Select2 v.3.3.2.
  131. */
  132. .select2-container .select2-choice .select2-arrow,
  133. .select2-container .select2-choice div /* 1 */ {
  134. border-left: none;
  135. background: none;
  136. @include reset-filter;
  137. }
  138. .select2-dropdown-open .select2-choice .select2-arrow,
  139. .select2-dropdown-open .select2-choice div /* 1 */ {
  140. border-left-color: transparent;
  141. background: none;
  142. @include reset-filter;
  143. }
  144. /**
  145. * Adjust the dropdown arrow button icon position for the single-select Select2 elements
  146. * to make it line up vertically now that we increased the height of .select2-container.
  147. *
  148. * 1. Class repetition to address missing .select2-chosen in Select2 v.3.3.2.
  149. */
  150. .select2-container .select2-choice .select2-arrow b,
  151. .select2-container .select2-choice div b /* 1 */ {
  152. background-position: 0 3px;
  153. }
  154. .select2-dropdown-open .select2-choice .select2-arrow b,
  155. .select2-dropdown-open .select2-choice div b /* 1 */ {
  156. background-position: -18px 3px;
  157. }
  158. .select2-container.input-sm .select2-choice .select2-arrow b,
  159. .input-group-sm .select2-container .select2-choice .select2-arrow b,
  160. .select2-container.input-sm .select2-choice div b, /* 1 */
  161. .input-group-sm .select2-container .select2-choice div b /* 1 */ {
  162. background-position: 0 1px;
  163. }
  164. .select2-dropdown-open.input-sm .select2-choice .select2-arrow b,
  165. .input-group-sm .select2-dropdown-open .select2-choice .select2-arrow b,
  166. .select2-dropdown-open.input-sm .select2-choice div b, /* 1 */
  167. .input-group-sm .select2-dropdown-open .select2-choice div b /* 1 */ {
  168. background-position: -18px 1px;
  169. }
  170. .select2-container.input-lg .select2-choice .select2-arrow b,
  171. .input-group-lg .select2-container .select2-choice .select2-arrow b,
  172. .select2-container.input-lg .select2-choice div b, /* 1 */
  173. .input-group-lg .select2-container .select2-choice div b /* 1 */ {
  174. background-position: 0 9px;
  175. }
  176. .select2-dropdown-open.input-lg .select2-choice .select2-arrow b,
  177. .input-group-lg .select2-dropdown-open .select2-choice .select2-arrow b,
  178. .select2-dropdown-open.input-lg .select2-choice div b, /* 1 */
  179. .input-group-lg .select2-dropdown-open .select2-choice div b /* 1 */ {
  180. background-position: -18px 9px;
  181. }
  182. /**
  183. * Address Bootstrap's validation states and change Select2's border colors and focus states.
  184. * Apply .has-warning, .has-danger or .has-succes to #select2-drop to match Bootstraps' colors.
  185. */
  186. @mixin validation-state-focus($color) {
  187. .select2-choice,
  188. .select2-choices {
  189. border-color: $color;
  190. }
  191. .select2-container-active .select2-choice,
  192. .select2-container-multi.select2-container-active .select2-choices {
  193. border-color: darken($color, 10%);
  194. $shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten($color, 20%);
  195. @include box-shadow($shadow);
  196. }
  197. &.select2-drop-active {
  198. border-color: darken($color, 10%);
  199. &.select2-drop.select2-drop-above {
  200. border-top-color: darken($color, 10%);
  201. }
  202. }
  203. }
  204. .has-warning {
  205. @include validation-state-focus($state-warning-text);
  206. }
  207. .has-error {
  208. @include validation-state-focus($state-danger-text);
  209. }
  210. .has-success {
  211. @include validation-state-focus($state-success-text);
  212. }
  213. /**
  214. * Make Select2's active-styles - applied to .select2-container when the widget receives focus -
  215. * fit Bootstrap 3's .form-element:focus appearance.
  216. */
  217. .select2-container-active .select2-choice,
  218. .select2-container-multi.select2-container-active .select2-choices {
  219. border-color: $input-border-focus;
  220. outline: none;
  221. $shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba($input-border-focus, 0.6);
  222. @include box-shadow($shadow);
  223. $transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
  224. @include transition($transition);
  225. }
  226. .select2-drop-active {
  227. border-color: $input-border-focus;
  228. }
  229. .select2-drop-auto-width,
  230. .select2-drop.select2-drop-above.select2-drop-active {
  231. border-top-color: $input-border-focus;
  232. }
  233. /**
  234. * Select2 widgets in Bootstrap Input Groups
  235. *
  236. * When Select2 widgets are combined with other elements using Bootstrap 3's
  237. * "Input Group" component, we don't want specific edges of the Select2 container
  238. * to have a border-radius.
  239. *
  240. * In Bootstrap 2, input groups required a markup where these style adjustments
  241. * could be bound to a CSS-class identifying if the additional elements are appended,
  242. * prepended or both.
  243. *
  244. * Bootstrap 3 doesn't rely on these classes anymore, so we have to use our own.
  245. * Use .select2-bootstrap-prepend and .select2-bootstrap-append on a Bootstrap 3 .input-group
  246. * to let the contained Select2 widget know which edges should not be rounded as they are
  247. * directly followed by another element.
  248. *
  249. * @see http://getbootstrap.com/components/#input-groups
  250. */
  251. .input-group.select2-bootstrap-prepend [class^="select2-choice"] {
  252. @include border-left-radius(0 !important);
  253. }
  254. .input-group.select2-bootstrap-append [class^="select2-choice"] {
  255. @include border-right-radius(0 !important);
  256. }
  257. .select2-dropdown-open [class^="select2-choice"] {
  258. @include border-bottom-radius(0 !important);
  259. }
  260. .select2-dropdown-open.select2-drop-above [class^="select2-choice"] {
  261. @include border-top-radius(0 !important);
  262. @include border-bottom-radius($input-border-radius !important);
  263. background: $btn-default-bg;
  264. filter: none;
  265. .input-group.select2-bootstrap-prepend & {
  266. @include border-left-radius(0 !important);
  267. }
  268. .input-group.select2-bootstrap-append & {
  269. @include border-right-radius(0 !important);
  270. }
  271. .input-group.input-group-sm.select2-bootstrap-prepend & {
  272. border-bottom-right-radius: $border-radius-small !important;
  273. }
  274. .input-group.input-group-lg.select2-bootstrap-prepend & {
  275. border-bottom-right-radius: $border-radius-large !important;
  276. }
  277. .input-group.input-group-sm.select2-bootstrap-append & {
  278. border-bottom-left-radius: $border-radius-small !important;
  279. }
  280. .input-group.input-group-lg.select2-bootstrap-append & {
  281. border-bottom-left-radius: $border-radius-large !important;
  282. }
  283. }
  284. /**
  285. * Adjust Select2's choices hover and selected styles to match Bootstrap 3's default dropdown styles.
  286. */
  287. .select2-results .select2-highlighted {
  288. color: $dropdown-link-active-color;
  289. background-color: $dropdown-link-active-bg;
  290. }
  291. /**
  292. * Adjust alignment of Bootstrap 3 buttons in Bootstrap 3 Input Groups to address
  293. * Multi Select2's height which - depending on how many elements have been selected -
  294. * may grown higher than their initial size.
  295. */
  296. .select2-bootstrap-append,
  297. .select2-bootstrap-prepend {
  298. .select2-container-multiple,
  299. .input-group-btn,
  300. .input-group-btn .btn {
  301. vertical-align: top;
  302. }
  303. }
  304. /**
  305. * Make Multi Select2's choices match Bootstrap 3's default button styles.
  306. */
  307. .select2-container-multi .select2-choices .select2-search-choice {
  308. color: $input-color;
  309. background: $btn-default-bg;
  310. border-color: $btn-default-border;
  311. @include reset-filter;
  312. -webkit-box-shadow: none;
  313. box-shadow: none;
  314. }
  315. .select2-container-multi .select2-choices .select2-search-choice-focus {
  316. background: darken($btn-default-bg, 8%);
  317. border-color: darken($btn-default-border, 12%);
  318. color: $btn-default-color;
  319. -webkit-box-shadow: none;
  320. box-shadow: none;
  321. }
  322. /**
  323. * Address Multi Select2's choice close-button vertical alignment.
  324. */
  325. .select2-search-choice-close {
  326. margin-top: -7px;
  327. top: 50%;
  328. }
  329. /**
  330. * Adjust the single Select2's clear button position (used to reset the select box
  331. * back to the placeholder value and visible once a selection is made
  332. * activated by Select2's "allowClear" option).
  333. */
  334. .select2-container .select2-choice abbr {
  335. top: 50%;
  336. }
  337. /**
  338. * Adjust "no results" and "selection limit" messages to make use
  339. * of Bootstrap 3's default "Alert" style.
  340. *
  341. * @see http://getbootstrap.com/components/#alerts-default
  342. */
  343. .select2-results .select2-no-results,
  344. .select2-results .select2-searching,
  345. .select2-results .select2-selection-limit {
  346. background-color: $state-warning-bg;
  347. color: $state-warning-text;
  348. }
  349. /**
  350. * Address disabled Select2 styles.
  351. *
  352. * 1. For Select2 v.3.3.2.
  353. * 2. Revert border-left:0 inherited from Select2's CSS to prevent the arrow
  354. * from jumping when switching from disabled to enabled state and vice versa.
  355. */
  356. .select2-container.select2-container-disabled {
  357. .select2-choice,
  358. .select2-choices {
  359. cursor: not-allowed;
  360. background-color: $input-bg-disabled;
  361. border-color: $input-border;
  362. .select2-arrow,
  363. div /* 1 */ {
  364. background-color: transparent;
  365. border-left: 1px solid transparent; /* 2 */
  366. }
  367. }
  368. }
  369. /**
  370. * Address Select2's loading indicator position - which should not stick
  371. * to the right edge of Select2's search input.
  372. *
  373. * 1. in .select2-search input
  374. * 2. in Multi Select2's .select2-search-field input
  375. * 3. in the status-message of infinite-scroll with remote data (@see http://ivaynberg.github.io/select2/#infinite)
  376. *
  377. * These styles alter Select2's default background-position of 100%
  378. * and supply the new background-position syntax to browsers which support it:
  379. *
  380. * 1. Android, Safari < 6/Mobile, IE<9: change to a relative background-position of 99%
  381. * 2. Chrome 25+, Firefox 13+, IE 9+, Opera 10.5+: use the new CSS3-background-position syntax
  382. *
  383. * @see http://www.w3.org/TR/css3-background/#background-position
  384. *
  385. * @todo Since both Select2 and Bootstrap 3 only support IE8 and above,
  386. * we could use the :after-pseudo-element to display the loading indicator.
  387. * Alternatively, we could supply an altered loading indicator image which already
  388. * contains an offset to the right.
  389. */
  390. .select2-search input.select2-active, /* 1 */
  391. .select2-container-multi .select2-choices .select2-search-field input.select2-active, /* 2 */
  392. .select2-more-results.select2-active /* 3 */ {
  393. background-position: 99%; /* 4 */
  394. background-position: right 4px center; /* 5 */
  395. }
  396. /**
  397. * To support Select2 pre v3.4.2 in combination with Bootstrap v3.2.0,
  398. * ensure that .select2-offscreen width, height and position can not be overwritten.
  399. *
  400. * This adresses changes in Bootstrap somewhere after the initial v3.0.0 which -
  401. * in combination with Select2's pre-v3.4.2 CSS missing the "!important" after
  402. * the following rules - allow Bootstrap to overwrite the latter, which results in
  403. * the original <select> element Select2 is replacing not be properly being hidden
  404. * when used in a "Bootstrap Input Group with Addon".
  405. **/
  406. .select2-offscreen,
  407. .select2-offscreen:focus {
  408. width: 1px !important;
  409. height: 1px !important;
  410. position: absolute !important;
  411. }