bootstrap-select.scss 9.2 KB

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