select2-bootstrap.min.scss 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /*! Select2 Bootstrap Theme v0.1.0-beta.4 | MIT License | github.com/select2/select2-bootstrap-theme */
  2. //
  3. // Variables
  4. // --------------------------------------------------
  5. @import "../../../../../sass/global/variables";
  6. // Bootstrap defaults not available as pre-defined variables
  7. // These should not be overridden.
  8. // @see https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_forms.scss#L127
  9. $form-control-default-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
  10. // @see https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/mixins/_forms.scss#L43
  11. $form-control-focus-box-shadow: $form-control-default-box-shadow, 0 0 8px rgba($input-border-focus, 0.6);
  12. // @see https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_forms.scss#L128
  13. $form-control-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
  14. // Custom variables
  15. // -------------------------
  16. $dropdown-arrow-color: $input-color-placeholder !default;
  17. $dropdown-box-shadow: 0 6px 12px rgba(0,0,0,.175) !default;
  18. $clear-selection-color: $dropdown-arrow-color !default;
  19. //
  20. // Mixins
  21. // --------------------------------------------------
  22. // @see https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_forms.scss#L115
  23. @mixin bootstrap-input-defaults {
  24. @include box-shadow($form-control-default-box-shadow);
  25. background-color: $input-bg;
  26. border: 1px solid $input-border;
  27. border-radius: $input-border-radius;
  28. color: $input-color;
  29. font-family: $font-family-base;
  30. font-size: $font-size-base;
  31. }
  32. // @see http://getbootstrap.com/css/#forms-control-validation
  33. // @see https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_forms.scss#L388
  34. @mixin validation-state-focus($color) {
  35. $shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten($color, 20%);
  36. .select2-dropdown,
  37. .select2-selection {
  38. border-color: $color;
  39. }
  40. .select2-container--focus .select2-selection,
  41. .select2-container--open .select2-selection {
  42. @include box-shadow($shadow);
  43. border-color: darken($color, 10%);
  44. }
  45. &.select2-drop-active {
  46. border-color: darken($color, 10%);
  47. &.select2-drop.select2-drop-above {
  48. border-top-color: darken($color, 10%);
  49. }
  50. }
  51. }
  52. // dropdown arrow when dropdown is open
  53. @mixin dropdown-arrow {
  54. .select2-selection--single {
  55. /**
  56. * Make the dropdown arrow point up while the dropdown is visible.
  57. */
  58. .select2-selection__arrow b {
  59. border-color: transparent transparent $dropdown-arrow-color transparent;
  60. border-width: 0 $caret-width-large $caret-width-large $caret-width-large;
  61. }
  62. }
  63. }
  64. .select2-container--bootstrap {
  65. display: block;
  66. /*------------------------------------*\
  67. #COMMON STYLES
  68. \*------------------------------------*/
  69. .select2-selection {
  70. @include bootstrap-input-defaults;
  71. outline: 0;
  72. }
  73. /**
  74. * Search field in the Select2 dropdown.
  75. */
  76. .select2-search--dropdown {
  77. .select2-search__field {
  78. @include bootstrap-input-defaults;
  79. }
  80. }
  81. /**
  82. * No outline for all search fields - in the dropdown
  83. * and inline in multi Select2s.
  84. */
  85. .select2-search__field {
  86. outline: 0;
  87. &::-webkit-input-placeholder {
  88. color: $input-color-placeholder;
  89. }
  90. /* Firefox 18- */
  91. &:-moz-placeholder {
  92. color: $input-color-placeholder;
  93. }
  94. /**
  95. * Firefox 19+
  96. *
  97. * @see http://stackoverflow.com/questions/24236240/color-for-styled-placeholder-text-is-muted-in-firefox
  98. */
  99. &::-moz-placeholder {
  100. color: $input-color-placeholder;
  101. opacity: 1;
  102. }
  103. &:-ms-input-placeholder {
  104. color: $input-color-placeholder;
  105. }
  106. }
  107. /**
  108. * Adjust Select2's choices hover and selected styles to match
  109. * Bootstrap 3's default dropdown styles.
  110. *
  111. * @see http://getbootstrap.com/components/#dropdowns
  112. */
  113. .select2-results__option {
  114. &[role=group] {
  115. padding: 0;
  116. }
  117. /**
  118. * Disabled results.
  119. *
  120. * @see https://select2.github.io/examples.html#disabled-results
  121. */
  122. &[aria-disabled=true] {
  123. color: $dropdown-link-disabled-color;
  124. cursor: $cursor-disabled;
  125. }
  126. /**
  127. * Hover state.
  128. */
  129. &[aria-selected=true] {
  130. background-color: $dropdown-link-hover-bg;
  131. color: $dropdown-link-hover-color;
  132. }
  133. /**
  134. * Selected state.
  135. */
  136. &--highlighted[aria-selected] {
  137. background-color: $dropdown-link-active-bg;
  138. color: $dropdown-link-active-color;
  139. }
  140. .select2-results__option {
  141. padding: $padding-base-vertical $padding-base-horizontal;
  142. .select2-results__group {
  143. padding-left: 0;
  144. }
  145. .select2-results__option {
  146. margin-left: -$padding-base-horizontal;
  147. padding-left: $padding-base-horizontal*2;
  148. .select2-results__option {
  149. margin-left: -$padding-base-horizontal*2;
  150. padding-left: $padding-base-horizontal*3;
  151. .select2-results__option {
  152. margin-left: -$padding-base-horizontal*3;
  153. padding-left: $padding-base-horizontal*4;
  154. .select2-results__option {
  155. margin-left: -$padding-base-horizontal*4;
  156. padding-left: $padding-base-horizontal*5;
  157. .select2-results__option {
  158. margin-left: -$padding-base-horizontal*5;
  159. padding-left: $padding-base-horizontal*6;
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. .select2-results__group {
  168. color: $dropdown-header-color;
  169. display: block;
  170. padding: $padding-base-vertical $padding-base-horizontal;
  171. font-size: $font-size-small;
  172. line-height: $line-height-base;
  173. white-space: nowrap;
  174. }
  175. &.select2-container--focus,
  176. &.select2-container--open {
  177. .select2-selection {
  178. @include box-shadow($form-control-focus-box-shadow);
  179. @include transition($form-control-transition);
  180. border-color: $input-border-focus;
  181. }
  182. }
  183. &.select2-container--open {
  184. /**
  185. * Make the dropdown arrow point up while the dropdown is visible.
  186. */
  187. .select2-selection .select2-selection__arrow b {
  188. border-color: transparent transparent $dropdown-arrow-color transparent;
  189. border-width: 0 $caret-width-base $caret-width-base $caret-width-base;
  190. }
  191. /**
  192. * Handle border radii of the container when the dropdown is showing.
  193. */
  194. &.select2-container--below {
  195. .select2-selection {
  196. @include border-bottom-radius(0);
  197. border-bottom-color: transparent;
  198. }
  199. }
  200. &.select2-container--above {
  201. .select2-selection {
  202. @include border-top-radius(0);
  203. border-top-color: transparent;
  204. }
  205. }
  206. }
  207. /**
  208. * Clear the selection.
  209. */
  210. .select2-selection__clear {
  211. color: $clear-selection-color;
  212. cursor: pointer;
  213. float: right;
  214. font-weight: bold;
  215. margin-right: 10px;
  216. &:hover {
  217. color: #333;
  218. }
  219. }
  220. /**
  221. * Address disabled Select2 styles.
  222. *
  223. * @see https://select2.github.io/examples.html#disabled
  224. * @see http://getbootstrap.com/css/#forms-control-disabled
  225. */
  226. &.select2-container--disabled {
  227. .select2-selection {
  228. border-color: $input-border;
  229. @include box-shadow(none);
  230. }
  231. .select2-selection,
  232. .select2-search__field {
  233. cursor: $cursor-disabled;
  234. }
  235. .select2-selection,
  236. .select2-selection--multiple .select2-selection__choice {
  237. background-color: $input-bg-disabled;
  238. }
  239. .select2-selection__clear,
  240. .select2-selection--multiple .select2-selection__choice__remove {
  241. display: none;
  242. }
  243. }
  244. /*------------------------------------*\
  245. #DROPDOWN
  246. \*------------------------------------*/
  247. /**
  248. * Dropdown border color and box-shadow.
  249. */
  250. .select2-dropdown {
  251. @include box-shadow($dropdown-box-shadow);
  252. border-color: $input-border-focus;
  253. overflow-x: hidden;
  254. margin-top: -1px;
  255. &--above {
  256. margin-top: 1px;
  257. }
  258. }
  259. /**
  260. * Limit the dropdown height.
  261. */
  262. .select2-results > .select2-results__options {
  263. max-height: 200px;
  264. overflow-y: auto;
  265. }
  266. /*------------------------------------*\
  267. #SINGLE SELECT2
  268. \*------------------------------------*/
  269. .select2-selection--single {
  270. height: $input-height-base;
  271. line-height: $line-height-base;
  272. padding: $padding-base-vertical $padding-base-horizontal + $caret-width-base*3 $padding-base-vertical $padding-base-horizontal;
  273. /**
  274. * Adjust the single Select2's dropdown arrow button appearance.
  275. */
  276. .select2-selection__arrow {
  277. position: absolute;
  278. bottom: 0;
  279. right: $padding-base-horizontal;
  280. top: 0;
  281. width: $caret-width-base;
  282. b {
  283. border-color: $dropdown-arrow-color transparent transparent transparent;
  284. border-style: solid;
  285. border-width: $caret-width-base $caret-width-base 0 $caret-width-base;
  286. height: 0;
  287. left: 0;
  288. margin-left: -$caret-width-base;
  289. margin-top: -$caret-width-base/2;
  290. position: absolute;
  291. top: 50%;
  292. width: 0;
  293. }
  294. }
  295. .select2-selection__rendered {
  296. color: $input-color;
  297. padding: 0;
  298. }
  299. .select2-selection__placeholder {
  300. color: $input-color-placeholder;
  301. }
  302. }
  303. /*------------------------------------*\
  304. #MULTIPLE SELECT2
  305. \*------------------------------------*/
  306. .select2-selection--multiple {
  307. min-height: $input-height-base;
  308. .select2-selection__rendered {
  309. box-sizing: border-box;
  310. display: block;
  311. line-height: $line-height-base;
  312. list-style: none;
  313. margin: 0;
  314. overflow: hidden;
  315. padding: 0;
  316. width: 100%;
  317. text-overflow: ellipsis;
  318. white-space: nowrap;
  319. }
  320. .select2-selection__placeholder {
  321. color: $input-color-placeholder;
  322. float: left;
  323. margin-top: 5px;
  324. }
  325. /**
  326. * Make Multi Select2's choices match Bootstrap 3's default button styles.
  327. */
  328. .select2-selection__choice {
  329. color: $input-color;
  330. background: $btn-default-bg;
  331. border: 1px solid $btn-default-border;
  332. border-radius: 4px;
  333. cursor: default;
  334. float: left;
  335. margin: ($padding-base-vertical - 1) 0 0 $padding-base-horizontal/2;
  336. padding: 0 $padding-base-vertical;
  337. }
  338. /**
  339. * Minus 2px borders.
  340. */
  341. .select2-search--inline {
  342. .select2-search__field {
  343. background: transparent;
  344. padding: 0 $padding-base-horizontal;
  345. height: $input-height-base - 2;
  346. line-height: $line-height-base;
  347. margin-top: 0;
  348. min-width: 5em;
  349. }
  350. }
  351. .select2-selection__choice__remove {
  352. color: #999;
  353. cursor: pointer;
  354. display: inline-block;
  355. font-weight: bold;
  356. margin-right: $padding-base-vertical / 2;
  357. &:hover {
  358. color: #333;
  359. }
  360. }
  361. /**
  362. * Clear the selection.
  363. */
  364. .select2-selection__clear {
  365. margin-top: $padding-base-vertical;
  366. }
  367. }
  368. /**
  369. * Address Bootstrap control sizing classes
  370. *
  371. * 1. Reset Bootstrap defaults.
  372. * 2. Adjust the dropdown arrow button icon position.
  373. *
  374. * @see http://getbootstrap.com/css/#forms-control-sizes
  375. */
  376. /* 1 */
  377. &.input-sm,
  378. &.input-lg {
  379. border-radius: 0;
  380. font-size: 12px;
  381. height: auto;
  382. line-height: 1;
  383. padding: 0;
  384. }
  385. &.input-sm,
  386. .input-group-sm &,
  387. .form-group-sm & {
  388. .select2-selection--single {
  389. border-radius: $border-radius-small;
  390. font-size: $font-size-small;
  391. height: $input-height-small;
  392. line-height: $line-height-small;
  393. padding: $padding-small-vertical $padding-small-horizontal + $caret-width-base*3 $padding-small-vertical $padding-small-horizontal;
  394. /* 2 */
  395. .select2-selection__arrow b {
  396. margin-left: -$padding-small-vertical;
  397. }
  398. }
  399. .select2-selection--multiple {
  400. min-height: $input-height-small;
  401. .select2-selection__choice {
  402. font-size: $font-size-small;
  403. line-height: $line-height-small;
  404. margin: ($padding-small-vertical - 1) 0 0 $padding-small-horizontal/2;
  405. padding: 0 $padding-small-vertical;
  406. }
  407. .select2-search--inline .select2-search__field {
  408. padding: 0 $padding-small-horizontal;
  409. font-size: $font-size-small;
  410. height: $input-height-small - 2;
  411. line-height: $line-height-small;
  412. }
  413. .select2-selection__clear {
  414. margin-top: $padding-small-vertical;
  415. }
  416. }
  417. }
  418. &.input-lg,
  419. .input-group-lg &,
  420. .form-group-lg & {
  421. .select2-selection--single {
  422. border-radius: $border-radius-large;
  423. font-size: $font-size-large;
  424. height: $input-height-large;
  425. line-height: $line-height-large;
  426. padding: $padding-large-vertical $padding-large-horizontal + $caret-width-large*3 $padding-large-vertical $padding-large-horizontal;
  427. /* 1 */
  428. .select2-selection__arrow {
  429. width: $caret-width-large;
  430. b {
  431. border-width: $caret-width-large $caret-width-large 0 $caret-width-large;
  432. margin-left: -$caret-width-large;
  433. margin-left: -$padding-large-vertical;
  434. margin-top: -$caret-width-large/2;
  435. }
  436. }
  437. }
  438. .select2-selection--multiple {
  439. min-height: $input-height-large;
  440. .select2-selection__choice {
  441. font-size: $font-size-large;
  442. line-height: $line-height-large;
  443. border-radius: 4px;
  444. margin: ($padding-large-vertical - 1) 0 0 $padding-large-horizontal/2;
  445. padding: 0 $padding-large-vertical;
  446. }
  447. .select2-search--inline .select2-search__field {
  448. padding: 0 $padding-large-horizontal;
  449. font-size: $font-size-large;
  450. height: $input-height-large - 2;
  451. line-height: $line-height-large;
  452. }
  453. .select2-selection__clear {
  454. margin-top: $padding-large-vertical;
  455. }
  456. }
  457. }
  458. &.input-lg.select2-container--open {
  459. @include dropdown-arrow;
  460. }
  461. .input-group-lg & {
  462. &.select2-container--open {
  463. @include dropdown-arrow;
  464. }
  465. }
  466. /*------------------------------------*\
  467. #RTL SUPPORT
  468. \*------------------------------------*/
  469. &[dir="rtl"] {
  470. /**
  471. * Single Select2
  472. *
  473. * 1. Makes sure that .select2-selection__placeholder is positioned
  474. * correctly.
  475. */
  476. .select2-selection--single {
  477. padding-left: $padding-base-horizontal + $caret-width-base*3;
  478. padding-right: $padding-base-horizontal;
  479. .select2-selection__rendered {
  480. padding-right: 0;
  481. padding-left: 0;
  482. text-align: right; /* 1 */
  483. }
  484. .select2-selection__clear {
  485. float: left;
  486. }
  487. .select2-selection__arrow {
  488. left: $padding-base-horizontal;
  489. right: auto;
  490. b {
  491. margin-left: 0;
  492. }
  493. }
  494. }
  495. /**
  496. * Multiple Select2
  497. */
  498. .select2-selection--multiple {
  499. .select2-selection__choice,
  500. .select2-selection__placeholder {
  501. float: right;
  502. }
  503. .select2-selection__choice {
  504. margin-left: 0;
  505. margin-right: $padding-base-horizontal/2;
  506. }
  507. .select2-selection__choice__remove {
  508. margin-left: 2px;
  509. margin-right: auto;
  510. }
  511. }
  512. }
  513. }
  514. /*------------------------------------*\
  515. #ADDITIONAL GOODIES
  516. \*------------------------------------*/
  517. /**
  518. * Address Bootstrap's validation states
  519. *
  520. * If a Select2 widget parent has one of Bootstrap's validation state modifier
  521. * classes, adjust Select2's border colors and focus states accordingly.
  522. * You may apply said classes to the Select2 dropdown (body > .select2-container)
  523. * via JavaScript match Bootstraps' to make its styles match.
  524. *
  525. * @see http://getbootstrap.com/css/#forms-control-validation
  526. */
  527. .has-warning {
  528. @include validation-state-focus($state-warning-text);
  529. }
  530. .has-error {
  531. @include validation-state-focus($state-danger-text);
  532. }
  533. .has-success {
  534. @include validation-state-focus($state-success-text);
  535. }
  536. /**
  537. * Select2 widgets in Bootstrap Input Groups
  538. *
  539. * When Select2 widgets are combined with other elements using Bootstraps
  540. * "Input Group" component, we don't want specific edges of the Select2
  541. * container to have a border-radius.
  542. *
  543. * Use .select2-bootstrap-prepend and .select2-bootstrap-append on
  544. * a Bootstrap 3 .input-group to let the contained Select2 widget know which
  545. * edges should not be rounded as they are directly followed by another element.
  546. *
  547. * @see http://getbootstrap.com/components/#input-groups
  548. */
  549. /**
  550. * Mimick Bootstraps .input-group .form-control styles.
  551. *
  552. * @see https://github.com/twbs/bootstrap/blob/master/less/input-groups.less
  553. */
  554. .input-group .select2-container--bootstrap {
  555. display: table;
  556. table-layout: fixed;
  557. position: relative;
  558. z-index: 2;
  559. float: left;
  560. width: 100%;
  561. margin-bottom: 0;
  562. }
  563. .input-group.select2-bootstrap-prepend .select2-container--bootstrap {
  564. .select2-selection {
  565. @include border-left-radius(0);
  566. }
  567. }
  568. .input-group.select2-bootstrap-append .select2-container--bootstrap {
  569. .select2-selection {
  570. @include border-right-radius(0);
  571. }
  572. }
  573. /**
  574. * Adjust alignment of Bootstrap buttons in Bootstrap Input Groups to address
  575. * Multi Select2's height which - depending on how many elements have been selected -
  576. * may grow taller than its initial size.
  577. *
  578. * @see http://getbootstrap.com/components/#input-groups
  579. */
  580. .select2-bootstrap-append,
  581. .select2-bootstrap-prepend {
  582. .select2-container--bootstrap,
  583. .input-group-btn,
  584. .input-group-btn .btn {
  585. vertical-align: top;
  586. }
  587. }
  588. /**
  589. * Temporary fix for https://github.com/select2/select2-bootstrap-theme/issues/9
  590. *
  591. * Provides `!important` for certain properties of the class applied to the
  592. * original `<select>` element to hide it.
  593. *
  594. * @see https://github.com/select2/select2/pull/3301
  595. * @see https://github.com/fk/select2/commit/31830c7b32cb3d8e1b12d5b434dee40a6e753ada
  596. */
  597. .form-control.select2-hidden-accessible {
  598. position: absolute !important;
  599. width: 1px !important;
  600. }
  601. /**
  602. * Display override for inline forms
  603. */
  604. .form-inline .select2-container--bootstrap {
  605. display: inline-block;
  606. }