forms.less 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. //
  2. // Forms
  3. // --------------------------------------------------
  4. // Normalize non-controls
  5. //
  6. // Restyle and baseline non-control form elements.
  7. legend {
  8. display: block;
  9. width: 100%;
  10. padding: 0;
  11. margin-bottom: @line-height-computed / 2;
  12. font-size: (@component-font-size-base * 1.6); // ~24px
  13. line-height: inherit;
  14. color: @legend-color;
  15. border-bottom: none;
  16. }
  17. // Normalize form controls
  18. // Textarea
  19. textarea {
  20. font-size: ceil((@font-size-base * 1.071)); // ~15px
  21. line-height: 24px;
  22. padding: 5px 11px;
  23. }
  24. // Search
  25. input[type="search"] {
  26. -webkit-appearance: none !important; // removes rounded corners for searchfields on iOS
  27. }
  28. // Label
  29. label {
  30. font-weight: normal;
  31. font-size: @component-font-size-base;
  32. line-height: 2.3; // ~36px
  33. }
  34. // Placeholder
  35. //
  36. // Placeholder text gets special styles because when browsers invalidate entire
  37. // lines if it doesn't understand a selector/
  38. .form-control {
  39. .placeholder(desaturate(lighten(@brand-primary, 45%), 15%));
  40. }
  41. // Common form controls
  42. //
  43. // Shared size and type resets for form controls. Apply `.form-control` to any
  44. // of the following form controls:
  45. //
  46. // select
  47. // textarea
  48. // input[type="text"]
  49. // input[type="password"]
  50. // input[type="datetime"]
  51. // input[type="datetime-local"]
  52. // input[type="date"]
  53. // input[type="month"]
  54. // input[type="time"]
  55. // input[type="week"]
  56. // input[type="number"]
  57. // input[type="email"]
  58. // input[type="url"]
  59. // input[type="search"]
  60. // input[type="tel"]
  61. // input[type="color"]
  62. .form-control {
  63. border: 2px solid @gray-light;
  64. color: @brand-primary;
  65. font-family: @font-family-base;
  66. font-size: @input-font-size-base;
  67. line-height: @input-line-height-base;
  68. padding: 8px 12px;
  69. height: 42px;
  70. border-radius: @input-border-radius;
  71. box-shadow: none;
  72. transition: border .25s linear, color .25s linear, background-color .25s linear;
  73. // Customize the `:focus` state
  74. .form-control-focus();
  75. // Disabled and read-only inputs
  76. // Note: HTML5 says that controls under a fieldset > legend:first-child won't
  77. // be disabled if the fieldset is disabled. Due to implementation difficulty,
  78. // we don't honor that edge case; we style them as disabled anyway.
  79. &[disabled],
  80. &[readonly],
  81. fieldset[disabled] & {
  82. background-color: @input-bg-disabled;
  83. border-color: mix(@gray, white, 40%);
  84. color: mix(@gray, white, 40%);
  85. cursor: default;
  86. .opacity(.7);
  87. }
  88. // Flat (without border)
  89. &.flat {
  90. border-color: transparent;
  91. &:hover {
  92. border-color: @gray-light;
  93. }
  94. &:focus {
  95. border-color: @brand-secondary;
  96. }
  97. }
  98. }
  99. // Form control sizing
  100. .input-sm,
  101. .form-group-sm .form-control {
  102. .input-size(@input-height-sm; 6px; 10px; @input-font-size-sm; @input-line-height-sm);
  103. }
  104. .input-lg,
  105. .form-group-lg .form-control {
  106. .input-size(@input-height-lg; 10px; 15px; @input-font-size-lg; @input-line-height-lg);
  107. }
  108. .input-hg,
  109. .form-group-hg .form-control {
  110. .input-size(@input-height-hg; 10px; 16px; @input-font-size-hg; @input-line-height-hg);
  111. }
  112. // Form control feedback states
  113. //
  114. // Apply contextual and semantic states to individual form controls.
  115. .form-control-feedback {
  116. position: absolute;
  117. top: 2px;
  118. right: 2px;
  119. margin-top: 1px;
  120. line-height: 36px;
  121. font-size: @input-icon-font-size;
  122. color: desaturate(lighten(@brand-primary, 45%), 15%);
  123. background-color: transparent;
  124. padding: 0 12px 0 0;
  125. border-radius: @input-border-radius;
  126. pointer-events: none;
  127. }
  128. .input-hg + .form-control-feedback,
  129. .control-feedback-hg {
  130. font-size: @input-icon-font-size-hg;
  131. line-height: 48px;
  132. padding-right: 16px;
  133. width: auto;
  134. height: 48px;
  135. }
  136. .input-lg + .form-control-feedback,
  137. .control-feedback-lg {
  138. font-size: @input-icon-font-size-lg;
  139. line-height: 40px;
  140. width: auto;
  141. height: 40px;
  142. padding-right: 15px;
  143. }
  144. .input-sm + .form-control-feedback,
  145. .control-feedback-sm {
  146. line-height: 29px;
  147. height: 29px;
  148. width: auto;
  149. padding-right: 10px;
  150. }
  151. // Feedback states
  152. .has-success {
  153. .form-control-validation(@brand-success; @brand-success);
  154. }
  155. .has-warning {
  156. .form-control-validation(@brand-warning; @brand-warning);
  157. }
  158. .has-error {
  159. .form-control-validation(@brand-danger; @brand-danger);
  160. }
  161. .form-control[disabled] + .form-control-feedback,
  162. .form-control[readonly] + .form-control-feedback,
  163. fieldset[disabled] .form-control + .form-control-feedback,
  164. .form-control.disabled + .form-control-feedback {
  165. cursor: @cursor-disabled;
  166. color: mix(@gray, white, 40%);
  167. background-color: transparent;
  168. .opacity(.7);
  169. }
  170. // Help text
  171. //
  172. // Apply to any element you wish to create light text for placement immediately
  173. // below a form control. Use for general help, formatting, or instructional text.
  174. .help-block {
  175. font-size: ceil((@component-font-size-base * 0.933));
  176. margin-bottom: 5px;
  177. color: mix(@brand-primary, @gray-light, 60%);
  178. }
  179. // Form groups
  180. //
  181. // Designed to help with the organization and spacing of vertical forms. For
  182. // horizontal forms, use the predefined grid classes.
  183. .form-group {
  184. position: relative;
  185. margin-bottom: 20px;
  186. }
  187. // Horizontal forms
  188. //
  189. // Horizontal forms are built on grid classes and allow you to create forms with
  190. // labels on the left and inputs on the right.
  191. .form-horizontal {
  192. // Consistent vertical alignment of radios and checkboxes
  193. //
  194. // Labels also get some reset styles, but that is scope to a media query below.
  195. .radio,
  196. .checkbox,
  197. .radio-inline,
  198. .checkbox-inline {
  199. margin-top: 0;
  200. margin-bottom: 0;
  201. padding-top: 0;
  202. }
  203. // Reset spacing and right align labels, but scope to media queries so that
  204. // labels on narrow viewports stack the same as a default form example.
  205. @media (min-width: @screen-sm-min) {
  206. .control-label {
  207. padding-top: 3px;
  208. padding-bottom: 3px;
  209. }
  210. }
  211. // Make form groups behave like rows
  212. .form-group {
  213. .make-row();
  214. }
  215. .form-control-static {
  216. padding-top: 6px;
  217. padding-bottom: 6px;
  218. }
  219. // Form group sizes
  220. //
  221. // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
  222. // inputs and labels within a `.form-group`.
  223. .form-group-hg {
  224. @media (min-width: @screen-sm-min) {
  225. .control-label {
  226. font-size: @input-font-size-hg;
  227. padding-top: 2px;
  228. padding-bottom: 0;
  229. }
  230. }
  231. .form-control {
  232. &:extend(.input-hg);
  233. }
  234. }
  235. .form-group-lg {
  236. @media (min-width: @screen-sm-min) {
  237. .control-label {
  238. font-size: @input-font-size-lg;
  239. padding-top: 3px;
  240. padding-bottom: 2px;
  241. }
  242. }
  243. }
  244. .form-group-sm {
  245. @media (min-width: @screen-sm-min) {
  246. .control-label {
  247. font-size: @input-font-size-sm;
  248. padding-top: 2px;
  249. padding-bottom: 2px;
  250. }
  251. }
  252. }
  253. }