bootstrap-select.scss 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. @import "variables";
  2. // Mixins
  3. @mixin cursor-disabled() {
  4. cursor: not-allowed;
  5. }
  6. @mixin box-sizing($fmt) {
  7. -webkit-box-sizing: $fmt;
  8. -moz-box-sizing: $fmt;
  9. box-sizing: $fmt;
  10. }
  11. @mixin box-shadow($fmt) {
  12. -webkit-box-shadow: $fmt;
  13. box-shadow: $fmt;
  14. }
  15. @function fade($color, $amnt) {
  16. @if $amnt > 1 {
  17. $amnt: $amnt / 100; // convert to percentage if int
  18. }
  19. @return rgba($color, $amnt);
  20. }
  21. // Rules
  22. select.bs-select-hidden,
  23. .bootstrap-select > select.bs-select-hidden,
  24. select.selectpicker {
  25. display: none !important;
  26. }
  27. .bootstrap-select {
  28. width: 220px \0; /*IE9 and below*/
  29. vertical-align: middle;
  30. // The selectpicker button
  31. > .dropdown-toggle {
  32. position: relative;
  33. width: 100%;
  34. // necessary for proper positioning of caret in Bootstrap 4 (pushes caret to the right)
  35. text-align: right;
  36. white-space: nowrap;
  37. // force caret to be vertically centered for Bootstrap 4 multi-line buttons
  38. display: inline-flex;
  39. align-items: center;
  40. justify-content: space-between;
  41. &:after {
  42. margin-top: -1px;
  43. }
  44. &.bs-placeholder {
  45. &,
  46. &:hover,
  47. &:focus,
  48. &:active {
  49. color: $input-color-placeholder;
  50. }
  51. &.btn-primary,
  52. &.btn-secondary,
  53. &.btn-success,
  54. &.btn-danger,
  55. &.btn-info,
  56. &.btn-dark {
  57. &,
  58. &:hover,
  59. &:focus,
  60. &:active {
  61. color: $input-alt-color-placeholder;
  62. }
  63. }
  64. }
  65. }
  66. > select {
  67. position: absolute !important;
  68. bottom: 0;
  69. left: 50%;
  70. display: block !important;
  71. width: 0.5px !important;
  72. height: 100% !important;
  73. padding: 0 !important;
  74. opacity: 0 !important;
  75. border: none;
  76. z-index: 0 !important;
  77. &.mobile-device {
  78. top: 0;
  79. left: 0;
  80. display: block !important;
  81. width: 100% !important;
  82. z-index: 2 !important;
  83. }
  84. }
  85. // Error display
  86. .has-error & .dropdown-toggle,
  87. .error & .dropdown-toggle,
  88. &.is-invalid .dropdown-toggle,
  89. .was-validated & .selectpicker:invalid + .dropdown-toggle {
  90. border-color: $color-red-error;
  91. }
  92. &.is-valid .dropdown-toggle,
  93. .was-validated & .selectpicker:valid + .dropdown-toggle {
  94. border-color: $color-green-success;
  95. }
  96. &.fit-width {
  97. width: auto !important;
  98. }
  99. &:not([class*="col-"]):not([class*="form-control"]):not(.input-group-btn) {
  100. width: $width-default;
  101. }
  102. > select.mobile-device:focus + .dropdown-toggle,
  103. .dropdown-toggle:focus {
  104. outline: thin dotted #333333 !important;
  105. outline: 5px auto -webkit-focus-ring-color !important;
  106. outline-offset: -2px;
  107. }
  108. }
  109. // The selectpicker components
  110. .bootstrap-select {
  111. &.form-control {
  112. margin-bottom: 0;
  113. padding: 0;
  114. border: none;
  115. :not(.input-group) > &:not([class*="col-"]) {
  116. width: 100%;
  117. }
  118. &.input-group-btn {
  119. float: none;
  120. z-index: auto;
  121. }
  122. }
  123. .form-inline &,
  124. .form-inline &.form-control:not([class*="col-"]) {
  125. width: auto;
  126. }
  127. &:not(.input-group-btn),
  128. &[class*="col-"] {
  129. float: none;
  130. display: inline-block;
  131. margin-left: 0;
  132. }
  133. // Forces the pull to the right, if necessary
  134. &,
  135. &[class*="col-"],
  136. .row &[class*="col-"] {
  137. &.dropdown-menu-right {
  138. float: right;
  139. }
  140. }
  141. .form-inline &,
  142. .form-horizontal &,
  143. .form-group & {
  144. margin-bottom: 0;
  145. }
  146. .form-group-lg &.form-control,
  147. .form-group-sm &.form-control {
  148. padding: 0;
  149. .dropdown-toggle {
  150. height: 100%;
  151. font-size: inherit;
  152. line-height: inherit;
  153. border-radius: inherit;
  154. }
  155. }
  156. &.form-control-sm .dropdown-toggle,
  157. &.form-control-lg .dropdown-toggle {
  158. font-size: inherit;
  159. line-height: inherit;
  160. border-radius: inherit;
  161. }
  162. &.form-control-sm .dropdown-toggle {
  163. padding: $input-padding-y-sm $input-padding-x-sm;
  164. }
  165. &.form-control-lg .dropdown-toggle {
  166. padding: $input-padding-y-lg $input-padding-x-lg;
  167. }
  168. // Set the width of the live search (and any other form control within an inline form)
  169. // see https://github.com/silviomoreto/bootstrap-select/issues/685
  170. .form-inline & .form-control {
  171. width: 100%;
  172. }
  173. &.disabled,
  174. > .disabled {
  175. @include cursor-disabled();
  176. &:focus {
  177. outline: none !important;
  178. }
  179. }
  180. &.bs-container {
  181. position: absolute;
  182. top: 0;
  183. left: 0;
  184. height: 0 !important;
  185. padding: 0 !important;
  186. .dropdown-menu {
  187. z-index: $zindex-select-dropdown;
  188. }
  189. }
  190. // The selectpicker button
  191. .dropdown-toggle {
  192. .filter-option {
  193. position: static;
  194. top: 0;
  195. left: 0;
  196. float: left;
  197. height: 100%;
  198. width: 100%;
  199. text-align: left;
  200. overflow: hidden;
  201. flex: 0 1 auto; // for IE10
  202. @at-root .bs3#{&} {
  203. padding-right: inherit;
  204. }
  205. @at-root .input-group .bs3-has-addon#{&} {
  206. position: absolute;
  207. padding-top: inherit;
  208. padding-bottom: inherit;
  209. padding-left: inherit;
  210. float: none;
  211. .filter-option-inner {
  212. padding-right: inherit;
  213. }
  214. }
  215. }
  216. .filter-option-inner-inner {
  217. overflow: hidden;
  218. }
  219. // used to expand the height of the button when inside an input group
  220. .filter-expand {
  221. width: 0 !important;
  222. float: left;
  223. opacity: 0 !important;
  224. overflow: hidden;
  225. }
  226. .caret {
  227. position: absolute;
  228. top: 50%;
  229. right: 12px;
  230. margin-top: -2px;
  231. vertical-align: middle;
  232. }
  233. }
  234. .input-group &.form-control .dropdown-toggle {
  235. border-radius: inherit;
  236. }
  237. &[class*="col-"] .dropdown-toggle {
  238. width: 100%;
  239. }
  240. // The selectpicker dropdown
  241. .dropdown-menu {
  242. min-width: 100%;
  243. @include box-sizing(border-box);
  244. > .inner:focus {
  245. outline: none !important;
  246. }
  247. &.inner {
  248. position: static;
  249. float: none;
  250. border: 0;
  251. padding: 0;
  252. margin: 0;
  253. border-radius: 0;
  254. box-shadow: none;
  255. }
  256. li {
  257. position: relative;
  258. &.active small {
  259. color: $input-alt-color-placeholder !important;
  260. }
  261. &.disabled a {
  262. @include cursor-disabled();
  263. }
  264. a {
  265. cursor: pointer;
  266. user-select: none;
  267. &.opt {
  268. position: relative;
  269. padding-left: 2.25em;
  270. }
  271. span.check-mark {
  272. display: none;
  273. }
  274. span.text {
  275. display: inline-block;
  276. }
  277. }
  278. small {
  279. padding-left: 0.5em;
  280. }
  281. }
  282. .notify {
  283. position: absolute;
  284. bottom: 5px;
  285. width: 96%;
  286. margin: 0 2%;
  287. min-height: 26px;
  288. padding: 3px 5px;
  289. background: rgb(245, 245, 245);
  290. border: 1px solid rgb(227, 227, 227);
  291. @include box-shadow(inset 0 1px 1px fade(rgb(0, 0, 0), 5));
  292. pointer-events: none;
  293. opacity: 0.9;
  294. @include box-sizing(border-box);
  295. }
  296. }
  297. .no-results {
  298. padding: 3px;
  299. background: #f5f5f5;
  300. margin: 0 5px;
  301. white-space: nowrap;
  302. }
  303. &.fit-width .dropdown-toggle {
  304. .filter-option {
  305. position: static;
  306. display: inline;
  307. padding: 0;
  308. width: auto;
  309. }
  310. .filter-option-inner,
  311. .filter-option-inner-inner {
  312. display: inline;
  313. }
  314. .bs-caret:before {
  315. content: '\00a0';
  316. }
  317. .caret {
  318. position: static;
  319. top: auto;
  320. margin-top: -1px;
  321. }
  322. }
  323. &.show-tick .dropdown-menu {
  324. .selected span.check-mark {
  325. position: absolute;
  326. display: inline-block;
  327. right: 15px;
  328. top: 5px;
  329. }
  330. li a span.text {
  331. margin-right: 34px;
  332. }
  333. }
  334. // default check mark for use without an icon font
  335. .bs-ok-default:after {
  336. content: '';
  337. display: block;
  338. width: 0.5em;
  339. height: 1em;
  340. border-style: solid;
  341. border-width: 0 0.26em 0.26em 0;
  342. transform: rotate(45deg);
  343. }
  344. }
  345. .bootstrap-select.show-menu-arrow {
  346. &.open > .dropdown-toggle,
  347. &.show > .dropdown-toggle {
  348. z-index: ($zindex-select-dropdown + 1);
  349. }
  350. .dropdown-toggle .filter-option {
  351. &:before {
  352. content: '';
  353. border-left: 7px solid transparent;
  354. border-right: 7px solid transparent;
  355. border-bottom: 7px solid $color-grey-arrow;
  356. position: absolute;
  357. bottom: -4px;
  358. left: 9px;
  359. display: none;
  360. }
  361. &:after {
  362. content: '';
  363. border-left: 6px solid transparent;
  364. border-right: 6px solid transparent;
  365. border-bottom: 6px solid white;
  366. position: absolute;
  367. bottom: -4px;
  368. left: 10px;
  369. display: none;
  370. }
  371. }
  372. &.dropup .dropdown-toggle .filter-option {
  373. &:before {
  374. bottom: auto;
  375. top: -4px;
  376. border-top: 7px solid $color-grey-arrow;
  377. border-bottom: 0;
  378. }
  379. &:after {
  380. bottom: auto;
  381. top: -4px;
  382. border-top: 6px solid white;
  383. border-bottom: 0;
  384. }
  385. }
  386. &.pull-right .dropdown-toggle .filter-option {
  387. &:before {
  388. right: 12px;
  389. left: auto;
  390. }
  391. &:after {
  392. right: 13px;
  393. left: auto;
  394. }
  395. }
  396. &.open > .dropdown-toggle .filter-option,
  397. &.show > .dropdown-toggle .filter-option {
  398. &:before,
  399. &:after {
  400. display: block;
  401. }
  402. }
  403. }
  404. .bs-searchbox,
  405. .bs-actionsbox,
  406. .bs-donebutton {
  407. padding: 4px 8px;
  408. }
  409. .bs-actionsbox {
  410. width: 100%;
  411. @include box-sizing(border-box);
  412. & .btn-group button {
  413. width: 50%;
  414. }
  415. }
  416. .bs-donebutton {
  417. float: left;
  418. width: 100%;
  419. @include box-sizing(border-box);
  420. & .btn-group button {
  421. width: 100%;
  422. }
  423. }
  424. .bs-searchbox {
  425. & + .bs-actionsbox {
  426. padding: 0 8px 4px;
  427. }
  428. & .form-control {
  429. margin-bottom: 0;
  430. width: 100%;
  431. float: none;
  432. }
  433. }