Layout von Websiten mit Bootstrap und Foundation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_custom-forms.scss 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. // Embedded icons from Open Iconic.
  2. // Released under MIT and copyright 2014 Waybury.
  3. // https://useiconic.com/open
  4. // Checkboxes and radios
  5. //
  6. // Base class takes care of all the key behavioral aspects.
  7. .custom-control {
  8. position: relative;
  9. display: block;
  10. min-height: $font-size-base * $line-height-base;
  11. padding-left: $custom-control-gutter + $custom-control-indicator-size;
  12. }
  13. .custom-control-inline {
  14. display: inline-flex;
  15. margin-right: $custom-control-spacer-x;
  16. }
  17. .custom-control-input {
  18. position: absolute;
  19. left: 0;
  20. z-index: -1; // Put the input behind the label so it doesn't overlay text
  21. width: $custom-control-indicator-size;
  22. height: ($font-size-base * $line-height-base + $custom-control-indicator-size) / 2;
  23. opacity: 0;
  24. &:checked ~ .custom-control-label::before {
  25. color: $custom-control-indicator-checked-color;
  26. border-color: $custom-control-indicator-checked-border-color;
  27. @include gradient-bg($custom-control-indicator-checked-bg);
  28. @include box-shadow($custom-control-indicator-checked-box-shadow);
  29. }
  30. &:focus ~ .custom-control-label::before {
  31. // the mixin is not used here to make sure there is feedback
  32. @if $enable-shadows {
  33. box-shadow: $input-box-shadow, $input-focus-box-shadow;
  34. } @else {
  35. box-shadow: $custom-control-indicator-focus-box-shadow;
  36. }
  37. }
  38. &:focus:not(:checked) ~ .custom-control-label::before {
  39. border-color: $custom-control-indicator-focus-border-color;
  40. }
  41. &:not(:disabled):active ~ .custom-control-label::before {
  42. color: $custom-control-indicator-active-color;
  43. background-color: $custom-control-indicator-active-bg;
  44. border-color: $custom-control-indicator-active-border-color;
  45. @include box-shadow($custom-control-indicator-active-box-shadow);
  46. }
  47. // Use [disabled] and :disabled to work around https://github.com/twbs/bootstrap/issues/28247
  48. &[disabled],
  49. &:disabled {
  50. ~ .custom-control-label {
  51. color: $custom-control-label-disabled-color;
  52. &::before {
  53. background-color: $custom-control-indicator-disabled-bg;
  54. }
  55. }
  56. }
  57. }
  58. // Custom control indicators
  59. //
  60. // Build the custom controls out of pseudo-elements.
  61. .custom-control-label {
  62. position: relative;
  63. margin-bottom: 0;
  64. color: $custom-control-label-color;
  65. vertical-align: top;
  66. cursor: $custom-control-cursor;
  67. // Background-color and (when enabled) gradient
  68. &::before {
  69. position: absolute;
  70. top: ($font-size-base * $line-height-base - $custom-control-indicator-size) / 2;
  71. left: -($custom-control-gutter + $custom-control-indicator-size);
  72. display: block;
  73. width: $custom-control-indicator-size;
  74. height: $custom-control-indicator-size;
  75. pointer-events: none;
  76. content: "";
  77. background-color: $custom-control-indicator-bg;
  78. border: $custom-control-indicator-border-color solid $custom-control-indicator-border-width;
  79. @include box-shadow($custom-control-indicator-box-shadow);
  80. }
  81. // Foreground (icon)
  82. &::after {
  83. position: absolute;
  84. top: ($font-size-base * $line-height-base - $custom-control-indicator-size) / 2;
  85. left: -($custom-control-gutter + $custom-control-indicator-size);
  86. display: block;
  87. width: $custom-control-indicator-size;
  88. height: $custom-control-indicator-size;
  89. content: "";
  90. background: no-repeat 50% / #{$custom-control-indicator-bg-size};
  91. }
  92. }
  93. // Checkboxes
  94. //
  95. // Tweak just a few things for checkboxes.
  96. .custom-checkbox {
  97. .custom-control-label::before {
  98. @include border-radius($custom-checkbox-indicator-border-radius);
  99. }
  100. .custom-control-input:checked ~ .custom-control-label {
  101. &::after {
  102. background-image: escape-svg($custom-checkbox-indicator-icon-checked);
  103. }
  104. }
  105. .custom-control-input:indeterminate ~ .custom-control-label {
  106. &::before {
  107. border-color: $custom-checkbox-indicator-indeterminate-border-color;
  108. @include gradient-bg($custom-checkbox-indicator-indeterminate-bg);
  109. @include box-shadow($custom-checkbox-indicator-indeterminate-box-shadow);
  110. }
  111. &::after {
  112. background-image: escape-svg($custom-checkbox-indicator-icon-indeterminate);
  113. }
  114. }
  115. .custom-control-input:disabled {
  116. &:checked ~ .custom-control-label::before {
  117. background-color: $custom-control-indicator-checked-disabled-bg;
  118. }
  119. &:indeterminate ~ .custom-control-label::before {
  120. background-color: $custom-control-indicator-checked-disabled-bg;
  121. }
  122. }
  123. }
  124. // Radios
  125. //
  126. // Tweak just a few things for radios.
  127. .custom-radio {
  128. .custom-control-label::before {
  129. // stylelint-disable-next-line property-blacklist
  130. border-radius: $custom-radio-indicator-border-radius;
  131. }
  132. .custom-control-input:checked ~ .custom-control-label {
  133. &::after {
  134. background-image: escape-svg($custom-radio-indicator-icon-checked);
  135. }
  136. }
  137. .custom-control-input:disabled {
  138. &:checked ~ .custom-control-label::before {
  139. background-color: $custom-control-indicator-checked-disabled-bg;
  140. }
  141. }
  142. }
  143. // switches
  144. //
  145. // Tweak a few things for switches
  146. .custom-switch {
  147. padding-left: $custom-switch-width + $custom-control-gutter;
  148. .custom-control-label {
  149. &::before {
  150. left: -($custom-switch-width + $custom-control-gutter);
  151. width: $custom-switch-width;
  152. pointer-events: all;
  153. // stylelint-disable-next-line property-blacklist
  154. border-radius: $custom-switch-indicator-border-radius;
  155. }
  156. &::after {
  157. top: add(($font-size-base * $line-height-base - $custom-control-indicator-size) / 2, $custom-control-indicator-border-width * 2);
  158. left: add(-($custom-switch-width + $custom-control-gutter), $custom-control-indicator-border-width * 2);
  159. width: $custom-switch-indicator-size;
  160. height: $custom-switch-indicator-size;
  161. background-color: $custom-control-indicator-border-color;
  162. // stylelint-disable-next-line property-blacklist
  163. border-radius: $custom-switch-indicator-border-radius;
  164. @include transition(transform .15s ease-in-out, $custom-forms-transition);
  165. }
  166. }
  167. .custom-control-input:checked ~ .custom-control-label {
  168. &::after {
  169. background-color: $custom-control-indicator-bg;
  170. transform: translateX($custom-switch-width - $custom-control-indicator-size);
  171. }
  172. }
  173. .custom-control-input:disabled {
  174. &:checked ~ .custom-control-label::before {
  175. background-color: $custom-control-indicator-checked-disabled-bg;
  176. }
  177. }
  178. }
  179. // Select
  180. //
  181. // Replaces the browser default select with a custom one, mostly pulled from
  182. // https://primer.github.io/.
  183. //
  184. .custom-select {
  185. display: inline-block;
  186. width: 100%;
  187. height: $custom-select-height;
  188. padding: $custom-select-padding-y ($custom-select-padding-x + $custom-select-indicator-padding) $custom-select-padding-y $custom-select-padding-x;
  189. font-family: $custom-select-font-family;
  190. @include font-size($custom-select-font-size);
  191. font-weight: $custom-select-font-weight;
  192. line-height: $custom-select-line-height;
  193. color: $custom-select-color;
  194. vertical-align: middle;
  195. background: $custom-select-bg $custom-select-background;
  196. border: $custom-select-border-width solid $custom-select-border-color;
  197. @include border-radius($custom-select-border-radius, 0);
  198. @include box-shadow($custom-select-box-shadow);
  199. appearance: none;
  200. &:focus {
  201. border-color: $custom-select-focus-border-color;
  202. outline: 0;
  203. @if $enable-shadows {
  204. @include box-shadow($custom-select-box-shadow, $custom-select-focus-box-shadow);
  205. } @else {
  206. // Avoid using mixin so we can pass custom focus shadow properly
  207. box-shadow: $custom-select-focus-box-shadow;
  208. }
  209. &::-ms-value {
  210. // For visual consistency with other platforms/browsers,
  211. // suppress the default white text on blue background highlight given to
  212. // the selected option text when the (still closed) <select> receives focus
  213. // in IE and (under certain conditions) Edge.
  214. // See https://github.com/twbs/bootstrap/issues/19398.
  215. color: $input-color;
  216. background-color: $input-bg;
  217. }
  218. }
  219. &[multiple],
  220. &[size]:not([size="1"]) {
  221. height: auto;
  222. padding-right: $custom-select-padding-x;
  223. background-image: none;
  224. }
  225. &:disabled {
  226. color: $custom-select-disabled-color;
  227. background-color: $custom-select-disabled-bg;
  228. }
  229. // Hides the default caret in IE11
  230. &::-ms-expand {
  231. display: none;
  232. }
  233. // Remove outline from select box in FF
  234. &:-moz-focusring {
  235. color: transparent;
  236. text-shadow: 0 0 0 $custom-select-color;
  237. }
  238. }
  239. .custom-select-sm {
  240. height: $custom-select-height-sm;
  241. padding-top: $custom-select-padding-y-sm;
  242. padding-bottom: $custom-select-padding-y-sm;
  243. padding-left: $custom-select-padding-x-sm;
  244. @include font-size($custom-select-font-size-sm);
  245. }
  246. .custom-select-lg {
  247. height: $custom-select-height-lg;
  248. padding-top: $custom-select-padding-y-lg;
  249. padding-bottom: $custom-select-padding-y-lg;
  250. padding-left: $custom-select-padding-x-lg;
  251. @include font-size($custom-select-font-size-lg);
  252. }
  253. // File
  254. //
  255. // Custom file input.
  256. .custom-file {
  257. position: relative;
  258. display: inline-block;
  259. width: 100%;
  260. height: $custom-file-height;
  261. margin-bottom: 0;
  262. }
  263. .custom-file-input {
  264. position: relative;
  265. z-index: 2;
  266. width: 100%;
  267. height: $custom-file-height;
  268. margin: 0;
  269. opacity: 0;
  270. &:focus ~ .custom-file-label {
  271. border-color: $custom-file-focus-border-color;
  272. box-shadow: $custom-file-focus-box-shadow;
  273. }
  274. // Use [disabled] and :disabled to work around https://github.com/twbs/bootstrap/issues/28247
  275. &[disabled] ~ .custom-file-label,
  276. &:disabled ~ .custom-file-label {
  277. background-color: $custom-file-disabled-bg;
  278. }
  279. @each $lang, $value in $custom-file-text {
  280. &:lang(#{$lang}) ~ .custom-file-label::after {
  281. content: $value;
  282. }
  283. }
  284. ~ .custom-file-label[data-browse]::after {
  285. content: attr(data-browse);
  286. }
  287. }
  288. .custom-file-label {
  289. position: absolute;
  290. top: 0;
  291. right: 0;
  292. left: 0;
  293. z-index: 1;
  294. height: $custom-file-height;
  295. padding: $custom-file-padding-y $custom-file-padding-x;
  296. font-family: $custom-file-font-family;
  297. font-weight: $custom-file-font-weight;
  298. line-height: $custom-file-line-height;
  299. color: $custom-file-color;
  300. background-color: $custom-file-bg;
  301. border: $custom-file-border-width solid $custom-file-border-color;
  302. @include border-radius($custom-file-border-radius);
  303. @include box-shadow($custom-file-box-shadow);
  304. &::after {
  305. position: absolute;
  306. top: 0;
  307. right: 0;
  308. bottom: 0;
  309. z-index: 3;
  310. display: block;
  311. height: $custom-file-height-inner;
  312. padding: $custom-file-padding-y $custom-file-padding-x;
  313. line-height: $custom-file-line-height;
  314. color: $custom-file-button-color;
  315. content: "Browse";
  316. @include gradient-bg($custom-file-button-bg);
  317. border-left: inherit;
  318. @include border-radius(0 $custom-file-border-radius $custom-file-border-radius 0);
  319. }
  320. }
  321. // Range
  322. //
  323. // Style range inputs the same across browsers. Vendor-specific rules for pseudo
  324. // elements cannot be mixed. As such, there are no shared styles for focus or
  325. // active states on prefixed selectors.
  326. .custom-range {
  327. width: 100%;
  328. height: add($custom-range-thumb-height, $custom-range-thumb-focus-box-shadow-width * 2);
  329. padding: 0; // Need to reset padding
  330. background-color: transparent;
  331. appearance: none;
  332. &:focus {
  333. outline: none;
  334. // Pseudo-elements must be split across multiple rulesets to have an effect.
  335. // No box-shadow() mixin for focus accessibility.
  336. &::-webkit-slider-thumb { box-shadow: $custom-range-thumb-focus-box-shadow; }
  337. &::-moz-range-thumb { box-shadow: $custom-range-thumb-focus-box-shadow; }
  338. &::-ms-thumb { box-shadow: $custom-range-thumb-focus-box-shadow; }
  339. }
  340. &::-moz-focus-outer {
  341. border: 0;
  342. }
  343. &::-webkit-slider-thumb {
  344. width: $custom-range-thumb-width;
  345. height: $custom-range-thumb-height;
  346. margin-top: ($custom-range-track-height - $custom-range-thumb-height) / 2; // Webkit specific
  347. @include gradient-bg($custom-range-thumb-bg);
  348. border: $custom-range-thumb-border;
  349. @include border-radius($custom-range-thumb-border-radius);
  350. @include box-shadow($custom-range-thumb-box-shadow);
  351. @include transition($custom-forms-transition);
  352. appearance: none;
  353. &:active {
  354. @include gradient-bg($custom-range-thumb-active-bg);
  355. }
  356. }
  357. &::-webkit-slider-runnable-track {
  358. width: $custom-range-track-width;
  359. height: $custom-range-track-height;
  360. color: transparent; // Why?
  361. cursor: $custom-range-track-cursor;
  362. background-color: $custom-range-track-bg;
  363. border-color: transparent;
  364. @include border-radius($custom-range-track-border-radius);
  365. @include box-shadow($custom-range-track-box-shadow);
  366. }
  367. &::-moz-range-thumb {
  368. width: $custom-range-thumb-width;
  369. height: $custom-range-thumb-height;
  370. @include gradient-bg($custom-range-thumb-bg);
  371. border: $custom-range-thumb-border;
  372. @include border-radius($custom-range-thumb-border-radius);
  373. @include box-shadow($custom-range-thumb-box-shadow);
  374. @include transition($custom-forms-transition);
  375. appearance: none;
  376. &:active {
  377. @include gradient-bg($custom-range-thumb-active-bg);
  378. }
  379. }
  380. &::-moz-range-track {
  381. width: $custom-range-track-width;
  382. height: $custom-range-track-height;
  383. color: transparent;
  384. cursor: $custom-range-track-cursor;
  385. background-color: $custom-range-track-bg;
  386. border-color: transparent; // Firefox specific?
  387. @include border-radius($custom-range-track-border-radius);
  388. @include box-shadow($custom-range-track-box-shadow);
  389. }
  390. &::-ms-thumb {
  391. width: $custom-range-thumb-width;
  392. height: $custom-range-thumb-height;
  393. margin-top: 0; // Edge specific
  394. margin-right: $custom-range-thumb-focus-box-shadow-width; // Workaround that overflowed box-shadow is hidden.
  395. margin-left: $custom-range-thumb-focus-box-shadow-width; // Workaround that overflowed box-shadow is hidden.
  396. @include gradient-bg($custom-range-thumb-bg);
  397. border: $custom-range-thumb-border;
  398. @include border-radius($custom-range-thumb-border-radius);
  399. @include box-shadow($custom-range-thumb-box-shadow);
  400. @include transition($custom-forms-transition);
  401. appearance: none;
  402. &:active {
  403. @include gradient-bg($custom-range-thumb-active-bg);
  404. }
  405. }
  406. &::-ms-track {
  407. width: $custom-range-track-width;
  408. height: $custom-range-track-height;
  409. color: transparent;
  410. cursor: $custom-range-track-cursor;
  411. background-color: transparent;
  412. border-color: transparent;
  413. border-width: $custom-range-thumb-height / 2;
  414. @include box-shadow($custom-range-track-box-shadow);
  415. }
  416. &::-ms-fill-lower {
  417. background-color: $custom-range-track-bg;
  418. @include border-radius($custom-range-track-border-radius);
  419. }
  420. &::-ms-fill-upper {
  421. margin-right: 15px; // arbitrary?
  422. background-color: $custom-range-track-bg;
  423. @include border-radius($custom-range-track-border-radius);
  424. }
  425. &:disabled {
  426. &::-webkit-slider-thumb {
  427. background-color: $custom-range-thumb-disabled-bg;
  428. }
  429. &::-webkit-slider-runnable-track {
  430. cursor: default;
  431. }
  432. &::-moz-range-thumb {
  433. background-color: $custom-range-thumb-disabled-bg;
  434. }
  435. &::-moz-range-track {
  436. cursor: default;
  437. }
  438. &::-ms-thumb {
  439. background-color: $custom-range-thumb-disabled-bg;
  440. }
  441. }
  442. }
  443. .custom-control-label::before,
  444. .custom-file-label,
  445. .custom-select {
  446. @include transition($custom-forms-transition);
  447. }