3.0.0 -> 3.0.1
[bootswatch] / bower_components / bootstrap / less / forms.less
1 //
2 // Forms
3 // --------------------------------------------------
4
5
6 // Normalize non-controls
7 //
8 // Restyle and baseline non-control form elements.
9
10 fieldset {
11   padding: 0;
12   margin: 0;
13   border: 0;
14 }
15
16 legend {
17   display: block;
18   width: 100%;
19   padding: 0;
20   margin-bottom: @line-height-computed;
21   font-size: (@font-size-base * 1.5);
22   line-height: inherit;
23   color: @legend-color;
24   border: 0;
25   border-bottom: 1px solid @legend-border-color;
26 }
27
28 label {
29   display: inline-block;
30   margin-bottom: 5px;
31   font-weight: bold;
32 }
33
34
35 // Normalize form controls
36
37 // Override content-box in Normalize (* isn't specific enough)
38 input[type="search"] {
39   .box-sizing(border-box);
40 }
41
42 // Position radios and checkboxes better
43 input[type="radio"],
44 input[type="checkbox"] {
45   margin: 4px 0 0;
46   margin-top: 1px \9; /* IE8-9 */
47   line-height: normal;
48 }
49
50 // Set the height of select and file controls to match text inputs
51 input[type="file"] {
52   display: block;
53 }
54
55 // Make multiple select elements height not fixed
56 select[multiple],
57 select[size] {
58   height: auto;
59 }
60
61 // Fix optgroup Firefox bug per https://github.com/twbs/bootstrap/issues/7611
62 select optgroup {
63   font-size: inherit;
64   font-style: inherit;
65   font-family: inherit;
66 }
67
68 // Focus for select, file, radio, and checkbox
69 input[type="file"]:focus,
70 input[type="radio"]:focus,
71 input[type="checkbox"]:focus {
72   .tab-focus();
73 }
74
75 // Fix for Chrome number input
76 // Setting certain font-sizes causes the `I` bar to appear on hover of the bottom increment button.
77 // See https://github.com/twbs/bootstrap/issues/8350 for more.
78 input[type="number"] {
79   &::-webkit-outer-spin-button,
80   &::-webkit-inner-spin-button {
81     height: auto;
82   }
83 }
84
85 // Adjust output element
86 output {
87   display: block;
88   padding-top: (@padding-base-vertical + 1);
89   font-size: @font-size-base;
90   line-height: @line-height-base;
91   color: @input-color;
92   vertical-align: middle;
93 }
94
95 // Placeholder
96 //
97 // Placeholder text gets special styles because when browsers invalidate entire
98 // lines if it doesn't understand a selector/
99 .form-control {
100   .placeholder();
101 }
102
103
104 // Common form controls
105 //
106 // Shared size and type resets for form controls. Apply `.form-control` to any
107 // of the following form controls:
108 //
109 // select
110 // textarea
111 // input[type="text"]
112 // input[type="password"]
113 // input[type="datetime"]
114 // input[type="datetime-local"]
115 // input[type="date"]
116 // input[type="month"]
117 // input[type="time"]
118 // input[type="week"]
119 // input[type="number"]
120 // input[type="email"]
121 // input[type="url"]
122 // input[type="search"]
123 // input[type="tel"]
124 // input[type="color"]
125
126 .form-control {
127   display: block;
128   width: 100%;
129   height: @input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
130   padding: @padding-base-vertical @padding-base-horizontal;
131   font-size: @font-size-base;
132   line-height: @line-height-base;
133   color: @input-color;
134   vertical-align: middle;
135   background-color: @input-bg;
136   background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
137   border: 1px solid @input-border;
138   border-radius: @input-border-radius;
139   .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
140   .transition(~"border-color ease-in-out .15s, box-shadow ease-in-out .15s");
141
142   // Customize the `:focus` state to imitate native WebKit styles.
143   .form-control-focus();
144
145   // Disabled and read-only inputs
146   // Note: HTML5 says that controls under a fieldset > legend:first-child won't
147   // be disabled if the fieldset is disabled. Due to implementation difficulty,
148   // we don't honor that edge case; we style them as disabled anyway.
149   &[disabled],
150   &[readonly],
151   fieldset[disabled] & {
152     cursor: not-allowed;
153     background-color: @input-bg-disabled;
154   }
155
156   // Reset height for `textarea`s
157   textarea& {
158     height: auto;
159   }
160 }
161
162
163 // Form groups
164 //
165 // Designed to help with the organization and spacing of vertical forms. For
166 // horizontal forms, use the predefined grid classes.
167
168 .form-group {
169   margin-bottom: 15px;
170 }
171
172
173 // Checkboxes and radios
174 //
175 // Indent the labels to position radios/checkboxes as hanging controls.
176
177 .radio,
178 .checkbox {
179   display: block;
180   min-height: @line-height-computed; // clear the floating input if there is no label text
181   margin-top: 10px;
182   margin-bottom: 10px;
183   padding-left: 20px;
184   vertical-align: middle;
185   label {
186     display: inline;
187     margin-bottom: 0;
188     font-weight: normal;
189     cursor: pointer;
190   }
191 }
192 .radio input[type="radio"],
193 .radio-inline input[type="radio"],
194 .checkbox input[type="checkbox"],
195 .checkbox-inline input[type="checkbox"] {
196   float: left;
197   margin-left: -20px;
198 }
199 .radio + .radio,
200 .checkbox + .checkbox {
201   margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
202 }
203
204 // Radios and checkboxes on same line
205 .radio-inline,
206 .checkbox-inline {
207   display: inline-block;
208   padding-left: 20px;
209   margin-bottom: 0;
210   vertical-align: middle;
211   font-weight: normal;
212   cursor: pointer;
213 }
214 .radio-inline + .radio-inline,
215 .checkbox-inline + .checkbox-inline {
216   margin-top: 0;
217   margin-left: 10px; // space out consecutive inline controls
218 }
219
220 // Apply same disabled cursor tweak as for inputs
221 //
222 // Note: Neither radios nor checkboxes can be readonly.
223 input[type="radio"],
224 input[type="checkbox"],
225 .radio,
226 .radio-inline,
227 .checkbox,
228 .checkbox-inline {
229   &[disabled],
230   fieldset[disabled] & {
231     cursor: not-allowed;
232   }
233 }
234
235 // Form control sizing
236 .input-sm {
237   .input-size(@input-height-small; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
238 }
239
240 .input-lg {
241   .input-size(@input-height-large; @padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large);
242 }
243
244
245 // Form control feedback states
246 //
247 // Apply contextual and semantic states to individual form controls.
248
249 // Warning
250 .has-warning {
251   .form-control-validation(@state-warning-text; @state-warning-text; @state-warning-bg);
252 }
253 // Error
254 .has-error {
255   .form-control-validation(@state-danger-text; @state-danger-text; @state-danger-bg);
256 }
257 // Success
258 .has-success {
259   .form-control-validation(@state-success-text; @state-success-text; @state-success-bg);
260 }
261
262
263 // Static form control text
264 //
265 // Apply class to a `p` element to make any string of text align with labels in
266 // a horizontal form layout.
267
268 .form-control-static {
269   margin-bottom: 0; // Remove default margin from `p`
270 }
271
272
273 // Help text
274 //
275 // Apply to any element you wish to create light text for placement immediately
276 // below a form control. Use for general help, formatting, or instructional text.
277
278 .help-block {
279   display: block; // account for any element using help-block
280   margin-top: 5px;
281   margin-bottom: 10px;
282   color: lighten(@text-color, 25%); // lighten the text some for contrast
283 }
284
285
286
287 // Inline forms
288 //
289 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
290 // forms begin stacked on extra small (mobile) devices and then go inline when
291 // viewports reach <768px.
292 //
293 // Requires wrapping inputs and labels with `.form-group` for proper display of
294 // default HTML form controls and our custom form controls (e.g., input groups).
295 //
296 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
297
298 .form-inline {
299
300   // Kick in the inline
301   @media (min-width: @screen-sm) {
302     // Inline-block all the things for "inline"
303     .form-group  {
304       display: inline-block;
305       margin-bottom: 0;
306       vertical-align: middle;
307     }
308
309     // In navbar-form, allow folks to *not* use `.form-group`
310     .form-control {
311       display: inline-block;
312     }
313
314     // Remove default margin on radios/checkboxes that were used for stacking, and
315     // then undo the floating of radios and checkboxes to match (which also avoids
316     // a bug in WebKit: https://github.com/twbs/bootstrap/issues/1969).
317     .radio,
318     .checkbox {
319       display: inline-block;
320       margin-top: 0;
321       margin-bottom: 0;
322       padding-left: 0;
323     }
324     .radio input[type="radio"],
325     .checkbox input[type="checkbox"] {
326       float: none;
327       margin-left: 0;
328     }
329   }
330 }
331
332
333 // Horizontal forms
334 //
335 // Horizontal forms are built on grid classes and allow you to create forms with
336 // labels on the left and inputs on the right.
337
338 .form-horizontal {
339
340   // Consistent vertical alignment of labels, radios, and checkboxes
341   .control-label,
342   .radio,
343   .checkbox,
344   .radio-inline,
345   .checkbox-inline {
346     margin-top: 0;
347     margin-bottom: 0;
348     padding-top: (@padding-base-vertical + 1); // Default padding plus a border
349   }
350
351   // Make form groups behave like rows
352   .form-group {
353     .make-row();
354   }
355
356   .form-control-static {
357     padding-top: (@padding-base-vertical + 1);
358   }
359
360   // Only right align form labels here when the columns stop stacking
361   @media (min-width: @screen-sm-min) {
362     .control-label {
363       text-align: right;
364     }
365   }
366 }