[ADD] doc: new documentation, with training tutorials, and new scaffolding
[odoo/odoo.git] / doc / _themes / odoodoc / static / 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   // Chrome and Firefox set a `min-width: min-content;` on fieldsets,
15   // so we reset that to ensure it behaves more like a standard block element.
16   // See https://github.com/twbs/bootstrap/issues/12359.
17   min-width: 0;
18 }
19
20 legend {
21   display: block;
22   width: 100%;
23   padding: 0;
24   margin-bottom: @line-height-computed;
25   font-size: (@font-size-base * 1.5);
26   line-height: inherit;
27   color: @legend-color;
28   border: 0;
29   border-bottom: 1px solid @legend-border-color;
30 }
31
32 label {
33   display: inline-block;
34   max-width: 100%; // Force IE8 to wrap long content (see https://github.com/twbs/bootstrap/issues/13141)
35   margin-bottom: 5px;
36   font-weight: bold;
37 }
38
39
40 // Normalize form controls
41 //
42 // While most of our form styles require extra classes, some basic normalization
43 // is required to ensure optimum display with or without those classes to better
44 // address browser inconsistencies.
45
46 // Override content-box in Normalize (* isn't specific enough)
47 input[type="search"] {
48   .box-sizing(border-box);
49 }
50
51 // Position radios and checkboxes better
52 input[type="radio"],
53 input[type="checkbox"] {
54   margin: 4px 0 0;
55   margin-top: 1px \9; // IE8-9
56   line-height: normal;
57 }
58
59 // Set the height of file controls to match text inputs
60 input[type="file"] {
61   display: block;
62 }
63
64 // Make range inputs behave like textual form controls
65 input[type="range"] {
66   display: block;
67   width: 100%;
68 }
69
70 // Make multiple select elements height not fixed
71 select[multiple],
72 select[size] {
73   height: auto;
74 }
75
76 // Focus for file, radio, and checkbox
77 input[type="file"]:focus,
78 input[type="radio"]:focus,
79 input[type="checkbox"]:focus {
80   .tab-focus();
81 }
82
83 // Adjust output element
84 output {
85   display: block;
86   padding-top: (@padding-base-vertical + 1);
87   font-size: @font-size-base;
88   line-height: @line-height-base;
89   color: @input-color;
90 }
91
92
93 // Common form controls
94 //
95 // Shared size and type resets for form controls. Apply `.form-control` to any
96 // of the following form controls:
97 //
98 // select
99 // textarea
100 // input[type="text"]
101 // input[type="password"]
102 // input[type="datetime"]
103 // input[type="datetime-local"]
104 // input[type="date"]
105 // input[type="month"]
106 // input[type="time"]
107 // input[type="week"]
108 // input[type="number"]
109 // input[type="email"]
110 // input[type="url"]
111 // input[type="search"]
112 // input[type="tel"]
113 // input[type="color"]
114
115 .form-control {
116   display: block;
117   width: 100%;
118   height: @input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
119   padding: @padding-base-vertical @padding-base-horizontal;
120   font-size: @font-size-base;
121   line-height: @line-height-base;
122   color: @input-color;
123   background-color: @input-bg;
124   background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
125   border: 1px solid @input-border;
126   border-radius: @input-border-radius;
127   .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
128   .transition(~"border-color ease-in-out .15s, box-shadow ease-in-out .15s");
129
130   // Customize the `:focus` state to imitate native WebKit styles.
131   .form-control-focus();
132
133   // Placeholder
134   .placeholder();
135
136   // Disabled and read-only inputs
137   //
138   // HTML5 says that controls under a fieldset > legend:first-child won't be
139   // disabled if the fieldset is disabled. Due to implementation difficulty, we
140   // don't honor that edge case; we style them as disabled anyway.
141   &[disabled],
142   &[readonly],
143   fieldset[disabled] & {
144     cursor: not-allowed;
145     background-color: @input-bg-disabled;
146     opacity: 1; // iOS fix for unreadable disabled content
147   }
148
149   // Reset height for `textarea`s
150   textarea& {
151     height: auto;
152   }
153 }
154
155
156 // Search inputs in iOS
157 //
158 // This overrides the extra rounded corners on search inputs in iOS so that our
159 // `.form-control` class can properly style them. Note that this cannot simply
160 // be added to `.form-control` as it's not specific enough. For details, see
161 // https://github.com/twbs/bootstrap/issues/11586.
162
163 input[type="search"] {
164   -webkit-appearance: none;
165 }
166
167
168 // Special styles for iOS temporal inputs
169 //
170 // In Mobile Safari, setting `display: block` on temporal inputs causes the
171 // text within the input to become vertically misaligned.
172 // As a workaround, we set a pixel line-height that matches the
173 // given height of the input. Since this fucks up everything else, we have to
174 // appropriately reset it for Internet Explorer and the size variations.
175
176 input[type="date"],
177 input[type="time"],
178 input[type="datetime-local"],
179 input[type="month"] {
180   line-height: @input-height-base;
181   // IE8+ misaligns the text within date inputs, so we reset
182   line-height: @line-height-base ~"\0";
183
184   &.input-sm {
185     line-height: @input-height-small;
186   }
187   &.input-lg {
188     line-height: @input-height-large;
189   }
190 }
191
192
193 // Form groups
194 //
195 // Designed to help with the organization and spacing of vertical forms. For
196 // horizontal forms, use the predefined grid classes.
197
198 .form-group {
199   margin-bottom: 15px;
200 }
201
202
203 // Checkboxes and radios
204 //
205 // Indent the labels to position radios/checkboxes as hanging controls.
206
207 .radio,
208 .checkbox {
209   position: relative;
210   display: block;
211   min-height: @line-height-computed; // clear the floating input if there is no label text
212   margin-top: 10px;
213   margin-bottom: 10px;
214
215   label {
216     padding-left: 20px;
217     margin-bottom: 0;
218     font-weight: normal;
219     cursor: pointer;
220   }
221 }
222 .radio input[type="radio"],
223 .radio-inline input[type="radio"],
224 .checkbox input[type="checkbox"],
225 .checkbox-inline input[type="checkbox"] {
226   position: absolute;
227   margin-left: -20px;
228   margin-top: 4px \9;
229 }
230
231 .radio + .radio,
232 .checkbox + .checkbox {
233   margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
234 }
235
236 // Radios and checkboxes on same line
237 .radio-inline,
238 .checkbox-inline {
239   display: inline-block;
240   padding-left: 20px;
241   margin-bottom: 0;
242   vertical-align: middle;
243   font-weight: normal;
244   cursor: pointer;
245 }
246 .radio-inline + .radio-inline,
247 .checkbox-inline + .checkbox-inline {
248   margin-top: 0;
249   margin-left: 10px; // space out consecutive inline controls
250 }
251
252 // Apply same disabled cursor tweak as for inputs
253 // Some special care is needed because <label>s don't inherit their parent's `cursor`.
254 //
255 // Note: Neither radios nor checkboxes can be readonly.
256 input[type="radio"],
257 input[type="checkbox"] {
258   &[disabled],
259   &.disabled,
260   fieldset[disabled] & {
261     cursor: not-allowed;
262   }
263 }
264 // These classes are used directly on <label>s
265 .radio-inline,
266 .checkbox-inline {
267   &.disabled,
268   fieldset[disabled] & {
269     cursor: not-allowed;
270   }
271 }
272 // These classes are used on elements with <label> descendants
273 .radio,
274 .checkbox {
275   &.disabled,
276   fieldset[disabled] & {
277     label {
278       cursor: not-allowed;
279     }
280   }
281 }
282
283
284 // Static form control text
285 //
286 // Apply class to a `p` element to make any string of text align with labels in
287 // a horizontal form layout.
288
289 .form-control-static {
290   // Size it appropriately next to real form controls
291   padding-top: (@padding-base-vertical + 1);
292   padding-bottom: (@padding-base-vertical + 1);
293   // Remove default margin from `p`
294   margin-bottom: 0;
295
296   &.input-lg,
297   &.input-sm {
298     padding-left: 0;
299     padding-right: 0;
300   }
301 }
302
303
304 // Form control sizing
305 //
306 // Build on `.form-control` with modifier classes to decrease or increase the
307 // height and font-size of form controls.
308
309 .input-sm {
310   .input-size(@input-height-small; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
311 }
312
313 .input-lg {
314   .input-size(@input-height-large; @padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large);
315 }
316
317
318 // Form control feedback states
319 //
320 // Apply contextual and semantic states to individual form controls.
321
322 .has-feedback {
323   // Enable absolute positioning
324   position: relative;
325
326   // Ensure icons don't overlap text
327   .form-control {
328     padding-right: (@input-height-base * 1.25);
329   }
330 }
331 // Feedback icon (requires .glyphicon classes)
332 .form-control-feedback {
333   position: absolute;
334   top: (@line-height-computed + 5); // Height of the `label` and its margin
335   right: 0;
336   z-index: 2; // Ensure icon is above input groups
337   display: block;
338   width: @input-height-base;
339   height: @input-height-base;
340   line-height: @input-height-base;
341   text-align: center;
342 }
343 .input-lg + .form-control-feedback {
344   width: @input-height-large;
345   height: @input-height-large;
346   line-height: @input-height-large;
347 }
348 .input-sm + .form-control-feedback {
349   width: @input-height-small;
350   height: @input-height-small;
351   line-height: @input-height-small;
352 }
353
354 // Feedback states
355 .has-success {
356   .form-control-validation(@state-success-text; @state-success-text; @state-success-bg);
357 }
358 .has-warning {
359   .form-control-validation(@state-warning-text; @state-warning-text; @state-warning-bg);
360 }
361 .has-error {
362   .form-control-validation(@state-danger-text; @state-danger-text; @state-danger-bg);
363 }
364
365
366 // Reposition feedback icon if label is hidden with "screenreader only" state
367 .has-feedback label.sr-only ~ .form-control-feedback {
368   top: 0;
369 }
370
371
372 // Help text
373 //
374 // Apply to any element you wish to create light text for placement immediately
375 // below a form control. Use for general help, formatting, or instructional text.
376
377 .help-block {
378   display: block; // account for any element using help-block
379   margin-top: 5px;
380   margin-bottom: 10px;
381   color: lighten(@text-color, 25%); // lighten the text some for contrast
382 }
383
384
385
386 // Inline forms
387 //
388 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
389 // forms begin stacked on extra small (mobile) devices and then go inline when
390 // viewports reach <768px.
391 //
392 // Requires wrapping inputs and labels with `.form-group` for proper display of
393 // default HTML form controls and our custom form controls (e.g., input groups).
394 //
395 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
396
397 .form-inline {
398
399   // Kick in the inline
400   @media (min-width: @screen-sm-min) {
401     // Inline-block all the things for "inline"
402     .form-group {
403       display: inline-block;
404       margin-bottom: 0;
405       vertical-align: middle;
406     }
407
408     // In navbar-form, allow folks to *not* use `.form-group`
409     .form-control {
410       display: inline-block;
411       width: auto; // Prevent labels from stacking above inputs in `.form-group`
412       vertical-align: middle;
413     }
414
415     .input-group {
416       display: inline-table;
417       vertical-align: middle;
418
419       .input-group-addon,
420       .input-group-btn,
421       .form-control {
422         width: auto;
423       }
424     }
425
426     // Input groups need that 100% width though
427     .input-group > .form-control {
428       width: 100%;
429     }
430
431     .control-label {
432       margin-bottom: 0;
433       vertical-align: middle;
434     }
435
436     // Remove default margin on radios/checkboxes that were used for stacking, and
437     // then undo the floating of radios and checkboxes to match (which also avoids
438     // a bug in WebKit: https://github.com/twbs/bootstrap/issues/1969).
439     .radio,
440     .checkbox {
441       display: inline-block;
442       margin-top: 0;
443       margin-bottom: 0;
444       vertical-align: middle;
445
446       label {
447         padding-left: 0;
448       }
449     }
450     .radio input[type="radio"],
451     .checkbox input[type="checkbox"] {
452       position: relative;
453       margin-left: 0;
454     }
455
456     // Validation states
457     //
458     // Reposition the icon because it's now within a grid column and columns have
459     // `position: relative;` on them. Also accounts for the grid gutter padding.
460     .has-feedback .form-control-feedback {
461       top: 0;
462     }
463   }
464 }
465
466
467 // Horizontal forms
468 //
469 // Horizontal forms are built on grid classes and allow you to create forms with
470 // labels on the left and inputs on the right.
471
472 .form-horizontal {
473
474   // Consistent vertical alignment of radios and checkboxes
475   //
476   // Labels also get some reset styles, but that is scoped to a media query below.
477   .radio,
478   .checkbox,
479   .radio-inline,
480   .checkbox-inline {
481     margin-top: 0;
482     margin-bottom: 0;
483     padding-top: (@padding-base-vertical + 1); // Default padding plus a border
484   }
485   // Account for padding we're adding to ensure the alignment and of help text
486   // and other content below items
487   .radio,
488   .checkbox {
489     min-height: (@line-height-computed + (@padding-base-vertical + 1));
490   }
491
492   // Make form groups behave like rows
493   .form-group {
494     .make-row();
495   }
496
497   // Reset spacing and right align labels, but scope to media queries so that
498   // labels on narrow viewports stack the same as a default form example.
499   @media (min-width: @screen-sm-min) {
500     .control-label {
501       text-align: right;
502       margin-bottom: 0;
503       padding-top: (@padding-base-vertical + 1); // Default padding plus a border
504     }
505   }
506
507   // Validation states
508   //
509   // Reposition the icon because it's now within a grid column and columns have
510   // `position: relative;` on them. Also accounts for the grid gutter padding.
511   .has-feedback .form-control-feedback {
512     top: 0;
513     right: (@grid-gutter-width / 2);
514   }
515
516   // Form group sizes
517   //
518   // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
519   // inputs and labels within a `.form-group`.
520   .form-group-lg {
521     @media (min-width: @screen-sm-min) {
522       .control-label {
523         padding-top: ((@padding-large-vertical * @line-height-large) + 1);
524       }
525     }
526     .form-control {
527       &:extend(.input-lg);
528     }
529   }
530   .form-group-sm {
531     @media (min-width: @screen-sm-min) {
532       .control-label {
533         padding-top: (@padding-small-vertical + 1);
534       }
535     }
536     .form-control {
537       &:extend(.input-sm);
538     }
539   }
540 }