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 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // Form control focus state
  2. //
  3. // Generate a customized focus state and for any input with the specified color,
  4. // which defaults to the `$input-focus-border-color` variable.
  5. //
  6. // We highly encourage you to not customize the default value, but instead use
  7. // this to tweak colors on an as-needed basis. This aesthetic change is based on
  8. // WebKit's default styles, but applicable to a wider range of browsers. Its
  9. // usability and accessibility should be taken into account with any change.
  10. //
  11. // Example usage: change the default blue border and shadow to white for better
  12. // contrast against a dark gray background.
  13. @mixin form-control-focus($ignore-warning: false) {
  14. &:focus {
  15. color: $input-focus-color;
  16. background-color: $input-focus-bg;
  17. border-color: $input-focus-border-color;
  18. outline: 0;
  19. @if $enable-shadows {
  20. @include box-shadow($input-box-shadow, $input-focus-box-shadow);
  21. } @else {
  22. // Avoid using mixin so we can pass custom focus shadow properly
  23. box-shadow: $input-focus-box-shadow;
  24. }
  25. }
  26. @include deprecate("The `form-control-focus()` mixin", "v4.4.0", "v5", $ignore-warning);
  27. }
  28. // This mixin uses an `if()` technique to be compatible with Dart Sass
  29. // See https://github.com/sass/sass/issues/1873#issuecomment-152293725 for more details
  30. @mixin form-validation-state-selector($state) {
  31. @if ($state == "valid" or $state == "invalid") {
  32. .was-validated #{if(&, "&", "")}:#{$state},
  33. #{if(&, "&", "")}.is-#{$state} {
  34. @content;
  35. }
  36. } @else {
  37. #{if(&, "&", "")}.is-#{$state} {
  38. @content;
  39. }
  40. }
  41. }
  42. @mixin form-validation-state($state, $color, $icon) {
  43. .#{$state}-feedback {
  44. display: none;
  45. width: 100%;
  46. margin-top: $form-feedback-margin-top;
  47. @include font-size($form-feedback-font-size);
  48. color: $color;
  49. }
  50. .#{$state}-tooltip {
  51. position: absolute;
  52. top: 100%;
  53. z-index: 5;
  54. display: none;
  55. max-width: 100%; // Contain to parent when possible
  56. padding: $form-feedback-tooltip-padding-y $form-feedback-tooltip-padding-x;
  57. margin-top: .1rem;
  58. @include font-size($form-feedback-tooltip-font-size);
  59. line-height: $form-feedback-tooltip-line-height;
  60. color: color-yiq($color);
  61. background-color: rgba($color, $form-feedback-tooltip-opacity);
  62. @include border-radius($form-feedback-tooltip-border-radius);
  63. }
  64. @include form-validation-state-selector($state) {
  65. ~ .#{$state}-feedback,
  66. ~ .#{$state}-tooltip {
  67. display: block;
  68. }
  69. }
  70. .form-control {
  71. @include form-validation-state-selector($state) {
  72. border-color: $color;
  73. @if $enable-validation-icons {
  74. padding-right: $input-height-inner;
  75. background-image: escape-svg($icon);
  76. background-repeat: no-repeat;
  77. background-position: right $input-height-inner-quarter center;
  78. background-size: $input-height-inner-half $input-height-inner-half;
  79. }
  80. &:focus {
  81. border-color: $color;
  82. box-shadow: 0 0 0 $input-focus-width rgba($color, .25);
  83. }
  84. }
  85. }
  86. // stylelint-disable-next-line selector-no-qualifying-type
  87. textarea.form-control {
  88. @include form-validation-state-selector($state) {
  89. @if $enable-validation-icons {
  90. padding-right: $input-height-inner;
  91. background-position: top $input-height-inner-quarter right $input-height-inner-quarter;
  92. }
  93. }
  94. }
  95. .custom-select {
  96. @include form-validation-state-selector($state) {
  97. border-color: $color;
  98. @if $enable-validation-icons {
  99. padding-right: $custom-select-feedback-icon-padding-right;
  100. background: $custom-select-background, escape-svg($icon) $custom-select-bg no-repeat $custom-select-feedback-icon-position / $custom-select-feedback-icon-size;
  101. }
  102. &:focus {
  103. border-color: $color;
  104. box-shadow: 0 0 0 $input-focus-width rgba($color, .25);
  105. }
  106. }
  107. }
  108. .form-check-input {
  109. @include form-validation-state-selector($state) {
  110. ~ .form-check-label {
  111. color: $color;
  112. }
  113. ~ .#{$state}-feedback,
  114. ~ .#{$state}-tooltip {
  115. display: block;
  116. }
  117. }
  118. }
  119. .custom-control-input {
  120. @include form-validation-state-selector($state) {
  121. ~ .custom-control-label {
  122. color: $color;
  123. &::before {
  124. border-color: $color;
  125. }
  126. }
  127. &:checked {
  128. ~ .custom-control-label::before {
  129. border-color: lighten($color, 10%);
  130. @include gradient-bg(lighten($color, 10%));
  131. }
  132. }
  133. &:focus {
  134. ~ .custom-control-label::before {
  135. box-shadow: 0 0 0 $input-focus-width rgba($color, .25);
  136. }
  137. &:not(:checked) ~ .custom-control-label::before {
  138. border-color: $color;
  139. }
  140. }
  141. }
  142. }
  143. // custom file
  144. .custom-file-input {
  145. @include form-validation-state-selector($state) {
  146. ~ .custom-file-label {
  147. border-color: $color;
  148. }
  149. &:focus {
  150. ~ .custom-file-label {
  151. border-color: $color;
  152. box-shadow: 0 0 0 $input-focus-width rgba($color, .25);
  153. }
  154. }
  155. }
  156. }
  157. }