bootstrap-select.scss 8.8 KB

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