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.

_forms.scss 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. // stylelint-disable selector-no-qualifying-type
  2. //
  3. // Textual form controls
  4. //
  5. .form-control {
  6. display: block;
  7. width: 100%;
  8. height: $input-height;
  9. padding: $input-padding-y $input-padding-x;
  10. font-family: $input-font-family;
  11. @include font-size($input-font-size);
  12. font-weight: $input-font-weight;
  13. line-height: $input-line-height;
  14. color: $input-color;
  15. background-color: $input-bg;
  16. background-clip: padding-box;
  17. border: $input-border-width solid $input-border-color;
  18. // Note: This has no effect on <select>s in some browsers, due to the limited stylability of `<select>`s in CSS.
  19. @include border-radius($input-border-radius, 0);
  20. @include box-shadow($input-box-shadow);
  21. @include transition($input-transition);
  22. // Unstyle the caret on `<select>`s in IE10+.
  23. &::-ms-expand {
  24. background-color: transparent;
  25. border: 0;
  26. }
  27. // Remove select outline from select box in FF
  28. &:-moz-focusring {
  29. color: transparent;
  30. text-shadow: 0 0 0 $input-color;
  31. }
  32. // Customize the `:focus` state to imitate native WebKit styles.
  33. @include form-control-focus($ignore-warning: true);
  34. // Placeholder
  35. &::placeholder {
  36. color: $input-placeholder-color;
  37. // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526.
  38. opacity: 1;
  39. }
  40. // Disabled and read-only inputs
  41. //
  42. // HTML5 says that controls under a fieldset > legend:first-child won't be
  43. // disabled if the fieldset is disabled. Due to implementation difficulty, we
  44. // don't honor that edge case; we style them as disabled anyway.
  45. &:disabled,
  46. &[readonly] {
  47. background-color: $input-disabled-bg;
  48. // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
  49. opacity: 1;
  50. }
  51. }
  52. input[type="date"],
  53. input[type="time"],
  54. input[type="datetime-local"],
  55. input[type="month"] {
  56. &.form-control {
  57. appearance: none; // Fix appearance for date inputs in Safari
  58. }
  59. }
  60. select.form-control {
  61. &:focus::-ms-value {
  62. // Suppress the nested default white text on blue background highlight given to
  63. // the selected option text when the (still closed) <select> receives focus
  64. // in IE and (under certain conditions) Edge, as it looks bad and cannot be made to
  65. // match the appearance of the native widget.
  66. // See https://github.com/twbs/bootstrap/issues/19398.
  67. color: $input-color;
  68. background-color: $input-bg;
  69. }
  70. }
  71. // Make file inputs better match text inputs by forcing them to new lines.
  72. .form-control-file,
  73. .form-control-range {
  74. display: block;
  75. width: 100%;
  76. }
  77. //
  78. // Labels
  79. //
  80. // For use with horizontal and inline forms, when you need the label (or legend)
  81. // text to align with the form controls.
  82. .col-form-label {
  83. padding-top: add($input-padding-y, $input-border-width);
  84. padding-bottom: add($input-padding-y, $input-border-width);
  85. margin-bottom: 0; // Override the `<label>/<legend>` default
  86. @include font-size(inherit); // Override the `<legend>` default
  87. line-height: $input-line-height;
  88. }
  89. .col-form-label-lg {
  90. padding-top: add($input-padding-y-lg, $input-border-width);
  91. padding-bottom: add($input-padding-y-lg, $input-border-width);
  92. @include font-size($input-font-size-lg);
  93. line-height: $input-line-height-lg;
  94. }
  95. .col-form-label-sm {
  96. padding-top: add($input-padding-y-sm, $input-border-width);
  97. padding-bottom: add($input-padding-y-sm, $input-border-width);
  98. @include font-size($input-font-size-sm);
  99. line-height: $input-line-height-sm;
  100. }
  101. // Readonly controls as plain text
  102. //
  103. // Apply class to a readonly input to make it appear like regular plain
  104. // text (without any border, background color, focus indicator)
  105. .form-control-plaintext {
  106. display: block;
  107. width: 100%;
  108. padding: $input-padding-y 0;
  109. margin-bottom: 0; // match inputs if this class comes on inputs with default margins
  110. @include font-size($input-font-size);
  111. line-height: $input-line-height;
  112. color: $input-plaintext-color;
  113. background-color: transparent;
  114. border: solid transparent;
  115. border-width: $input-border-width 0;
  116. &.form-control-sm,
  117. &.form-control-lg {
  118. padding-right: 0;
  119. padding-left: 0;
  120. }
  121. }
  122. // Form control sizing
  123. //
  124. // Build on `.form-control` with modifier classes to decrease or increase the
  125. // height and font-size of form controls.
  126. //
  127. // Repeated in `_input_group.scss` to avoid Sass extend issues.
  128. .form-control-sm {
  129. height: $input-height-sm;
  130. padding: $input-padding-y-sm $input-padding-x-sm;
  131. @include font-size($input-font-size-sm);
  132. line-height: $input-line-height-sm;
  133. @include border-radius($input-border-radius-sm);
  134. }
  135. .form-control-lg {
  136. height: $input-height-lg;
  137. padding: $input-padding-y-lg $input-padding-x-lg;
  138. @include font-size($input-font-size-lg);
  139. line-height: $input-line-height-lg;
  140. @include border-radius($input-border-radius-lg);
  141. }
  142. // stylelint-disable-next-line no-duplicate-selectors
  143. select.form-control {
  144. &[size],
  145. &[multiple] {
  146. height: auto;
  147. }
  148. }
  149. textarea.form-control {
  150. height: auto;
  151. }
  152. // Form groups
  153. //
  154. // Designed to help with the organization and spacing of vertical forms. For
  155. // horizontal forms, use the predefined grid classes.
  156. .form-group {
  157. margin-bottom: $form-group-margin-bottom;
  158. }
  159. .form-text {
  160. display: block;
  161. margin-top: $form-text-margin-top;
  162. }
  163. // Form grid
  164. //
  165. // Special replacement for our grid system's `.row` for tighter form layouts.
  166. .form-row {
  167. display: flex;
  168. flex-wrap: wrap;
  169. margin-right: -$form-grid-gutter-width / 2;
  170. margin-left: -$form-grid-gutter-width / 2;
  171. > .col,
  172. > [class*="col-"] {
  173. padding-right: $form-grid-gutter-width / 2;
  174. padding-left: $form-grid-gutter-width / 2;
  175. }
  176. }
  177. // Checkboxes and radios
  178. //
  179. // Indent the labels to position radios/checkboxes as hanging controls.
  180. .form-check {
  181. position: relative;
  182. display: block;
  183. padding-left: $form-check-input-gutter;
  184. }
  185. .form-check-input {
  186. position: absolute;
  187. margin-top: $form-check-input-margin-y;
  188. margin-left: -$form-check-input-gutter;
  189. // Use [disabled] and :disabled for workaround https://github.com/twbs/bootstrap/issues/28247
  190. &[disabled] ~ .form-check-label,
  191. &:disabled ~ .form-check-label {
  192. color: $text-muted;
  193. }
  194. }
  195. .form-check-label {
  196. margin-bottom: 0; // Override default `<label>` bottom margin
  197. }
  198. .form-check-inline {
  199. display: inline-flex;
  200. align-items: center;
  201. padding-left: 0; // Override base .form-check
  202. margin-right: $form-check-inline-margin-x;
  203. // Undo .form-check-input defaults and add some `margin-right`.
  204. .form-check-input {
  205. position: static;
  206. margin-top: 0;
  207. margin-right: $form-check-inline-input-margin-x;
  208. margin-left: 0;
  209. }
  210. }
  211. // Form validation
  212. //
  213. // Provide feedback to users when form field values are valid or invalid. Works
  214. // primarily for client-side validation via scoped `:invalid` and `:valid`
  215. // pseudo-classes but also includes `.is-invalid` and `.is-valid` classes for
  216. // server side validation.
  217. @each $state, $data in $form-validation-states {
  218. @include form-validation-state($state, map-get($data, color), map-get($data, icon));
  219. }
  220. // Inline forms
  221. //
  222. // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
  223. // forms begin stacked on extra small (mobile) devices and then go inline when
  224. // viewports reach <768px.
  225. //
  226. // Requires wrapping inputs and labels with `.form-group` for proper display of
  227. // default HTML form controls and our custom form controls (e.g., input groups).
  228. .form-inline {
  229. display: flex;
  230. flex-flow: row wrap;
  231. align-items: center; // Prevent shorter elements from growing to same height as others (e.g., small buttons growing to normal sized button height)
  232. // Because we use flex, the initial sizing of checkboxes is collapsed and
  233. // doesn't occupy the full-width (which is what we want for xs grid tier),
  234. // so we force that here.
  235. .form-check {
  236. width: 100%;
  237. }
  238. // Kick in the inline
  239. @include media-breakpoint-up(sm) {
  240. label {
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. margin-bottom: 0;
  245. }
  246. // Inline-block all the things for "inline"
  247. .form-group {
  248. display: flex;
  249. flex: 0 0 auto;
  250. flex-flow: row wrap;
  251. align-items: center;
  252. margin-bottom: 0;
  253. }
  254. // Allow folks to *not* use `.form-group`
  255. .form-control {
  256. display: inline-block;
  257. width: auto; // Prevent labels from stacking above inputs in `.form-group`
  258. vertical-align: middle;
  259. }
  260. // Make static controls behave like regular ones
  261. .form-control-plaintext {
  262. display: inline-block;
  263. }
  264. .input-group,
  265. .custom-select {
  266. width: auto;
  267. }
  268. // Remove default margin on radios/checkboxes that were used for stacking, and
  269. // then undo the floating of radios and checkboxes to match.
  270. .form-check {
  271. display: flex;
  272. align-items: center;
  273. justify-content: center;
  274. width: auto;
  275. padding-left: 0;
  276. }
  277. .form-check-input {
  278. position: relative;
  279. flex-shrink: 0;
  280. margin-top: 0;
  281. margin-right: $form-check-input-margin-x;
  282. margin-left: 0;
  283. }
  284. .custom-control {
  285. align-items: center;
  286. justify-content: center;
  287. }
  288. .custom-control-label {
  289. margin-bottom: 0;
  290. }
  291. }
  292. }