3.0.2 -> 3.0.3
[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
96 // Common form controls
97 //
98 // Shared size and type resets for form controls. Apply `.form-control` to any
99 // of the following form controls:
100 //
101 // select
102 // textarea
103 // input[type="text"]
104 // input[type="password"]
105 // input[type="datetime"]
106 // input[type="datetime-local"]
107 // input[type="date"]
108 // input[type="month"]
109 // input[type="time"]
110 // input[type="week"]
111 // input[type="number"]
112 // input[type="email"]
113 // input[type="url"]
114 // input[type="search"]
115 // input[type="tel"]
116 // input[type="color"]
117
118 .form-control {
119   display: block;
120   width: 100%;
121   height: @input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
122   padding: @padding-base-vertical @padding-base-horizontal;
123   font-size: @font-size-base;
124   line-height: @line-height-base;
125   color: @input-color;
126   vertical-align: middle;
127   background-color: @input-bg;
128   background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
129   border: 1px solid @input-border;
130   border-radius: @input-border-radius;
131   .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
132   .transition(~"border-color ease-in-out .15s, box-shadow ease-in-out .15s");
133
134   // Customize the `:focus` state to imitate native WebKit styles.
135   .form-control-focus();
136
137   // Placeholder
138   //
139   // Placeholder text gets special styles because when browsers invalidate entire
140   // lines if it doesn't understand a selector/
141   .placeholder();
142
143   // Disabled and read-only inputs
144   // Note: HTML5 says that controls under a fieldset > legend:first-child won't
145   // be disabled if the fieldset is disabled. Due to implementation difficulty,
146   // we don't honor that edge case; we style them as disabled anyway.
147   &[disabled],
148   &[readonly],
149   fieldset[disabled] & {
150     cursor: not-allowed;
151     background-color: @input-bg-disabled;
152   }
153
154   // Reset height for `textarea`s
155   textarea& {
156     height: auto;
157   }
158 }
159
160
161 // Form groups
162 //
163 // Designed to help with the organization and spacing of vertical forms. For
164 // horizontal forms, use the predefined grid classes.
165
166 .form-group {
167   margin-bottom: 15px;
168 }
169
170
171 // Checkboxes and radios
172 //
173 // Indent the labels to position radios/checkboxes as hanging controls.
174
175 .radio,
176 .checkbox {
177   display: block;
178   min-height: @line-height-computed; // clear the floating input if there is no label text
179   margin-top: 10px;
180   margin-bottom: 10px;
181   padding-left: 20px;
182   vertical-align: middle;
183   label {
184     display: inline;
185     margin-bottom: 0;
186     font-weight: normal;
187     cursor: pointer;
188   }
189 }
190 .radio input[type="radio"],
191 .radio-inline input[type="radio"],
192 .checkbox input[type="checkbox"],
193 .checkbox-inline input[type="checkbox"] {
194   float: left;
195   margin-left: -20px;
196 }
197 .radio + .radio,
198 .checkbox + .checkbox {
199   margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
200 }
201
202 // Radios and checkboxes on same line
203 .radio-inline,
204 .checkbox-inline {
205   display: inline-block;
206   padding-left: 20px;
207   margin-bottom: 0;
208   vertical-align: middle;
209   font-weight: normal;
210   cursor: pointer;
211 }
212 .radio-inline + .radio-inline,
213 .checkbox-inline + .checkbox-inline {
214   margin-top: 0;
215   margin-left: 10px; // space out consecutive inline controls
216 }
217
218 // Apply same disabled cursor tweak as for inputs
219 //
220 // Note: Neither radios nor checkboxes can be readonly.
221 input[type="radio"],
222 input[type="checkbox"],
223 .radio,
224 .radio-inline,
225 .checkbox,
226 .checkbox-inline {
227   &[disabled],
228   fieldset[disabled] & {
229     cursor: not-allowed;
230   }
231 }
232
233 // Form control sizing
234 .input-sm {
235   .input-size(@input-height-small; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
236 }
237
238 .input-lg {
239   .input-size(@input-height-large; @padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large);
240 }
241
242
243 // Form control feedback states
244 //
245 // Apply contextual and semantic states to individual form controls.
246
247 // Warning
248 .has-warning {
249   .form-control-validation(@state-warning-text; @state-warning-text; @state-warning-bg);
250 }
251 // Error
252 .has-error {
253   .form-control-validation(@state-danger-text; @state-danger-text; @state-danger-bg);
254 }
255 // Success
256 .has-success {
257   .form-control-validation(@state-success-text; @state-success-text; @state-success-bg);
258 }
259
260
261 // Static form control text
262 //
263 // Apply class to a `p` element to make any string of text align with labels in
264 // a horizontal form layout.
265
266 .form-control-static {
267   margin-bottom: 0; // Remove default margin from `p`
268 }
269
270
271 // Help text
272 //
273 // Apply to any element you wish to create light text for placement immediately
274 // below a form control. Use for general help, formatting, or instructional text.
275
276 .help-block {
277   display: block; // account for any element using help-block
278   margin-top: 5px;
279   margin-bottom: 10px;
280   color: lighten(@text-color, 25%); // lighten the text some for contrast
281 }
282
283
284
285 // Inline forms
286 //
287 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
288 // forms begin stacked on extra small (mobile) devices and then go inline when
289 // viewports reach <768px.
290 //
291 // Requires wrapping inputs and labels with `.form-group` for proper display of
292 // default HTML form controls and our custom form controls (e.g., input groups).
293 //
294 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
295
296 .form-inline {
297
298   // Kick in the inline
299   @media (min-width: @screen-sm) {
300     // Inline-block all the things for "inline"
301     .form-group  {
302       display: inline-block;
303       margin-bottom: 0;
304       vertical-align: middle;
305     }
306
307     // In navbar-form, allow folks to *not* use `.form-group`
308     .form-control {
309       display: inline-block;
310     }
311
312     // Override `width: 100%;` when not within a `.form-group`
313     select.form-control {
314       width: auto;
315     }
316
317     // Remove default margin on radios/checkboxes that were used for stacking, and
318     // then undo the floating of radios and checkboxes to match (which also avoids
319     // a bug in WebKit: https://github.com/twbs/bootstrap/issues/1969).
320     .radio,
321     .checkbox {
322       display: inline-block;
323       margin-top: 0;
324       margin-bottom: 0;
325       padding-left: 0;
326     }
327     .radio input[type="radio"],
328     .checkbox input[type="checkbox"] {
329       float: none;
330       margin-left: 0;
331     }
332   }
333 }
334
335
336 // Horizontal forms
337 //
338 // Horizontal forms are built on grid classes and allow you to create forms with
339 // labels on the left and inputs on the right.
340
341 .form-horizontal {
342
343   // Consistent vertical alignment of labels, radios, and checkboxes
344   .control-label,
345   .radio,
346   .checkbox,
347   .radio-inline,
348   .checkbox-inline {
349     margin-top: 0;
350     margin-bottom: 0;
351     padding-top: (@padding-base-vertical + 1); // Default padding plus a border
352   }
353   // Account for padding we're adding to ensure the alignment and of help text
354   // and other content below items
355   .radio,
356   .checkbox {
357     min-height: @line-height-computed + (@padding-base-vertical + 1);
358   }
359
360   // Make form groups behave like rows
361   .form-group {
362     .make-row();
363   }
364
365   .form-control-static {
366     padding-top: (@padding-base-vertical + 1);
367   }
368
369   // Only right align form labels here when the columns stop stacking
370   @media (min-width: @screen-sm-min) {
371     .control-label {
372       text-align: right;
373     }
374   }
375 }