_form.scss 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. ///
  2. /// Dimension by HTML5 UP
  3. /// html5up.net | @ajlkn
  4. /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
  5. ///
  6. /* Form */
  7. form {
  8. margin: 0 0 _size(element-margin) 0;
  9. > :last-child {
  10. margin-bottom: 0;
  11. }
  12. > .fields {
  13. $gutter: (_size(element-margin) * 0.75);
  14. @include vendor('display', 'flex');
  15. @include vendor('flex-wrap', 'wrap');
  16. width: calc(100% + #{$gutter * 2});
  17. margin: ($gutter * -1) 0 _size(element-margin) ($gutter * -1);
  18. > .field {
  19. @include vendor('flex-grow', '0');
  20. @include vendor('flex-shrink', '0');
  21. padding: $gutter 0 0 $gutter;
  22. width: calc(100% - #{$gutter * 1});
  23. &.half {
  24. width: calc(50% - #{$gutter * 0.5});
  25. }
  26. &.third {
  27. width: calc(#{100% / 3} - #{$gutter * (1 / 3)});
  28. }
  29. &.quarter {
  30. width: calc(25% - #{$gutter * 0.25});
  31. }
  32. }
  33. }
  34. @include breakpoint('<=xsmall') {
  35. > .fields {
  36. $gutter: (_size(element-margin) * 0.75);
  37. width: calc(100% + #{$gutter * 2});
  38. margin: ($gutter * -1) 0 _size(element-margin) ($gutter * -1);
  39. > .field {
  40. padding: $gutter 0 0 $gutter;
  41. width: calc(100% - #{$gutter * 1});
  42. &.half {
  43. width: calc(100% - #{$gutter * 1});
  44. }
  45. &.third {
  46. width: calc(100% - #{$gutter * 1});
  47. }
  48. &.quarter {
  49. width: calc(100% - #{$gutter * 1});
  50. }
  51. }
  52. }
  53. }
  54. }
  55. label {
  56. color: _palette(fg-bold);
  57. display: block;
  58. font-size: 0.8rem;
  59. font-weight: _font(weight);
  60. letter-spacing: _font(letter-spacing);
  61. line-height: 1.5;
  62. margin: 0 0 (_size(element-margin) * 0.5) 0;
  63. text-transform: uppercase;
  64. }
  65. input[type="text"],
  66. input[type="password"],
  67. input[type="email"],
  68. input[type="tel"],
  69. select,
  70. textarea {
  71. @include vendor('appearance', 'none');
  72. @include vendor('transition', (
  73. 'border-color #{_duration(transition)} ease-in-out',
  74. 'box-shadow #{_duration(transition)} ease-in-out',
  75. 'background-color #{_duration(transition)} ease-in-out'
  76. ));
  77. background-color: transparent;
  78. border-radius: _size(border-radius);
  79. border: solid _size(border-width) _palette(border);
  80. color: inherit;
  81. display: block;
  82. outline: 0;
  83. padding: 0 1rem;
  84. text-decoration: none;
  85. width: 100%;
  86. &:invalid {
  87. box-shadow: none;
  88. }
  89. &:focus {
  90. background: _palette(border-bg);
  91. border-color: _palette(fg-bold);
  92. box-shadow: 0 0 0 _size(border-width) _palette(fg-bold);
  93. }
  94. }
  95. select {
  96. background-image: svg-url("<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40' preserveAspectRatio='none' viewBox='0 0 40 40'><path d='M9.4,12.3l10.4,10.4l10.4-10.4c0.2-0.2,0.5-0.4,0.9-0.4c0.3,0,0.6,0.1,0.9,0.4l3.3,3.3c0.2,0.2,0.4,0.5,0.4,0.9 c0,0.4-0.1,0.6-0.4,0.9L20.7,31.9c-0.2,0.2-0.5,0.4-0.9,0.4c-0.3,0-0.6-0.1-0.9-0.4L4.3,17.3c-0.2-0.2-0.4-0.5-0.4-0.9 c0-0.4,0.1-0.6,0.4-0.9l3.3-3.3c0.2-0.2,0.5-0.4,0.9-0.4S9.1,12.1,9.4,12.3z' fill='#{_palette(border)}' /></svg>");
  97. background-size: 1.25rem;
  98. background-repeat: no-repeat;
  99. background-position: calc(100% - 1rem) center;
  100. height: _size(element-height);
  101. padding-right: _size(element-height);
  102. text-overflow: ellipsis;
  103. option {
  104. color: _palette(fg);
  105. background: _palette(bg);
  106. }
  107. &:focus {
  108. &::-ms-value {
  109. background-color: transparent;
  110. }
  111. }
  112. &::-ms-expand {
  113. display: none;
  114. }
  115. }
  116. input[type="text"],
  117. input[type="password"],
  118. input[type="email"],
  119. select {
  120. height: _size(element-height);
  121. }
  122. textarea {
  123. padding: 0.75rem 1rem;
  124. }
  125. input[type="checkbox"],
  126. input[type="radio"], {
  127. @include vendor('appearance', 'none');
  128. display: block;
  129. float: left;
  130. margin-right: -2rem;
  131. opacity: 0;
  132. width: 1rem;
  133. z-index: -1;
  134. & + label {
  135. @include icon;
  136. @include vendor('user-select', 'none');
  137. color: _palette(fg);
  138. cursor: pointer;
  139. display: inline-block;
  140. font-size: 0.8rem;
  141. font-weight: _font(weight);
  142. margin: 0 0 (_size(element-margin) * 0.25) 0;
  143. padding-left: (_size(element-height) * 0.6) + 1rem;
  144. padding-right: 0.75rem;
  145. position: relative;
  146. &:before {
  147. @include vendor('transition', (
  148. 'border-color #{_duration(transition)} ease-in-out',
  149. 'box-shadow #{_duration(transition)} ease-in-out',
  150. 'background-color #{_duration(transition)} ease-in-out'
  151. ));
  152. border-radius: _size(border-radius);
  153. border: solid _size(border-width) _palette(border);
  154. content: '';
  155. display: inline-block;
  156. height: (_size(element-height) * 0.6);
  157. left: 0;
  158. //line-height: (_size(element-height) * 0.575);
  159. line-height: calc(#{_size(element-height) * 0.575} + 0em);
  160. position: absolute;
  161. text-align: center;
  162. top: -0.125rem;
  163. width: (_size(element-height) * 0.6);
  164. }
  165. }
  166. &:checked + label {
  167. &:before {
  168. background: _palette(fg-bold) !important;
  169. border-color: _palette(fg-bold) !important;
  170. color: _palette(bg);
  171. content: '\f00c';
  172. }
  173. }
  174. &:focus + label {
  175. &:before {
  176. background: _palette(border-bg);
  177. border-color: _palette(fg-bold);
  178. box-shadow: 0 0 0 _size(border-width) _palette(fg-bold);
  179. }
  180. }
  181. }
  182. input[type="checkbox"] {
  183. & + label {
  184. &:before {
  185. border-radius: _size(border-radius);
  186. }
  187. }
  188. }
  189. input[type="radio"] {
  190. & + label {
  191. &:before {
  192. border-radius: 100%;
  193. }
  194. }
  195. }
  196. ::-webkit-input-placeholder {
  197. color: _palette(fg-light) !important;
  198. opacity: 1.0;
  199. }
  200. :-moz-placeholder {
  201. color: _palette(fg-light) !important;
  202. opacity: 1.0;
  203. }
  204. ::-moz-placeholder {
  205. color: _palette(fg-light) !important;
  206. opacity: 1.0;
  207. }
  208. :-ms-input-placeholder {
  209. color: _palette(fg-light) !important;
  210. opacity: 1.0;
  211. }
  212. .formerize-placeholder {
  213. color: _palette(fg-light) !important;
  214. opacity: 1.0;
  215. }