forms.less 7.11 KB
Newer Older
1
/* Forms.less
2
 * Base styles for various input types, form layouts, and states
3
 * ------------------------------------------------------------- */
Jacob Thornton's avatar
Jacob Thornton committed
4

5

6
7
// FORM STYLES
// -----------
Jacob Thornton's avatar
Jacob Thornton committed
8
9
10

form {
  margin-bottom: @baseline;
11

Jacob Thornton's avatar
Jacob Thornton committed
12
13
14
15
16
17
18
19
20
  // Groups of fields with labels on top (legends)
  fieldset {
    margin-bottom: @baseline;
    padding-top: @baseline;
    legend {
      display: block;
      margin-left: 150px;
      font-size: 20px;
      line-height: 1;
Jacob Thornton's avatar
Jacob Thornton committed
21
22
      *margin: 0 0 5px 145px; /* IE6-7 */
      *line-height: 1.5; /* IE6-7 */
23
      color: @grayDark;
Jacob Thornton's avatar
Jacob Thornton committed
24
25
    }
  }
26

Jacob Thornton's avatar
Jacob Thornton committed
27
  // Parent element that clears floats and wraps labels and fields together
Mark Otto's avatar
Mark Otto committed
28
  .clearfix {
Jacob Thornton's avatar
Jacob Thornton committed
29
30
    margin-bottom: @baseline;
  }
31

Jacob Thornton's avatar
Jacob Thornton committed
32
33
  // Set font for forms
  label, input, select, textarea {
34
    #font > .sans-serif(normal,13px,normal);
Jacob Thornton's avatar
Jacob Thornton committed
35
  }
36

Jacob Thornton's avatar
Jacob Thornton committed
37
38
39
40
41
42
43
44
  // Float labels left
  label {
    padding-top: 6px;
    font-size: 13px;
    line-height: 18px;
    float: left;
    width: 130px;
    text-align: right;
45
    color: @grayDark;
Jacob Thornton's avatar
Jacob Thornton committed
46
  }
47

Jacob Thornton's avatar
Jacob Thornton committed
48
49
50
51
  // Shift over the inside div to align all label's relevant content
  div.input {
    margin-left: 150px;
  }
52

Jacob Thornton's avatar
Jacob Thornton committed
53
54
55
56
57
  // Checkboxs and radio buttons
  input[type=checkbox],
  input[type=radio] {
    cursor: pointer;
  }
58

Jacob Thornton's avatar
Jacob Thornton committed
59
60
61
62
63
64
  // Inputs, Textareas, Selects
  input[type=text],
  input[type=password],
  textarea,
  select,
  .uneditable-input {
65
    display: inline-block;
Jacob Thornton's avatar
Jacob Thornton committed
66
67
68
69
70
71
72
    width: 210px;
    margin: 0;
    padding: 4px;
    font-size: 13px;
    line-height: @baseline;
    height: @baseline;
    color: @gray;
73
    border: 1px solid #ccc;
Jacob Thornton's avatar
Jacob Thornton committed
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
    .border-radius(3px);
  }
  select,
  input[type=file] {
    height: @baseline * 1.5;
    line-height: @baseline * 1.5;
  }
  textarea {
    height: auto;
  }
  .uneditable-input {
    background-color: #eee;
    display: block;
    border-color: #ccc;
    .box-shadow(inset 0 1px 2px rgba(0,0,0,.075));
  }
90

91
92
93
94
95
96
97
  // Placeholder text gets special styles; can't be bundled together though for some reason
  :-moz-placeholder {
    color: @grayLight;
  }
  ::-webkit-input-placeholder {
    color: @grayLight;
  }
98

Jacob Thornton's avatar
Jacob Thornton committed
99
  // Focus states
100
101
  input[type=text],
  input[type=password],
Jacob Thornton's avatar
Jacob Thornton committed
102
103
104
  select, textarea {
    @transition: border linear .2s, box-shadow linear .2s;
    .transition(@transition);
105
    .box-shadow(inset 0 1px 3px rgba(0,0,0,.1));
Jacob Thornton's avatar
Jacob Thornton committed
106
  }
107
108
  input[type=text]:focus,
  input[type=password]:focus,
Jacob Thornton's avatar
Jacob Thornton committed
109
110
  textarea:focus {
    outline: none;
111
112
113
    border-color: rgba(82,168,236,.8);
    @shadow: inset 0 1px 3px rgba(0,0,0,.1), 0 0 8px rgba(82,168,236,.6);
    .box-shadow(@shadow);
Jacob Thornton's avatar
Jacob Thornton committed
114
  }
115

Jacob Thornton's avatar
Jacob Thornton committed
116
  // Error styles
Mark Otto's avatar
Mark Otto committed
117
  div.error {
Jacob Thornton's avatar
Jacob Thornton committed
118
119
120
121
122
    background: lighten(@red, 57%);
    padding: 10px 0;
    margin: -10px 0 10px;
    .border-radius(4px);
    @error-text: desaturate(lighten(@red, 25%), 25%);
123
124
125
    > label,
    span.help-inline,
    span.help-block {
Jacob Thornton's avatar
Jacob Thornton committed
126
127
      color: @red;
    }
128
129
    input[type=text],
    input[type=password],
Jacob Thornton's avatar
Jacob Thornton committed
130
131
132
133
134
135
136
137
    textarea {
      border-color: @error-text;
      .box-shadow(0 0 3px rgba(171,41,32,.25));
      &:focus {
        border-color: darken(@error-text, 10%);
        .box-shadow(0 0 6px rgba(171,41,32,.5));
      }
    }
Mark Otto's avatar
Mark Otto committed
138
139
    .input-prepend,
    .input-append {
Jacob Thornton's avatar
Jacob Thornton committed
140
141
142
143
144
145
146
      span.add-on {
        background: lighten(@red, 50%);
        border-color: @error-text;
        color: darken(@error-text, 10%);
      }
    }
  }
147

Jacob Thornton's avatar
Jacob Thornton committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
  // Form element sizes
  .input-mini, input.mini, textarea.mini, select.mini {
    width: 60px;
  }
  .input-small, input.small, textarea.small, select.small {
    width: 90px;
  }
  .input-medium, input.medium, textarea.medium, select.medium {
    width: 150px;
  }
  .input-large, input.large, textarea.large, select.large {
    width: 210px;
  }
  .input-xlarge, input.xlarge, textarea.xlarge, select.xlarge {
    width: 270px;
  }
  .input-xxlarge, input.xxlarge, textarea.xxlarge, select.xxlarge {
    width: 530px;
  }
  textarea.xxlarge {
    overflow-y: scroll;
  }
170

Jacob Thornton's avatar
Jacob Thornton committed
171
172
173
174
175
176
177
178
179
180
181
  // Turn off focus for disabled (read-only) form elements
  input[readonly]:focus,
  textarea[readonly]:focus,
  input.disabled {
    background: #f5f5f5;
    border-color: #ddd;
    .box-shadow(none);
  }
}

// Actions (the buttons)
Mark Otto's avatar
Mark Otto committed
182
.actions {
Jacob Thornton's avatar
Jacob Thornton committed
183
184
185
186
187
188
  background: #f5f5f5;
  margin-top: @baseline;
  margin-bottom: @baseline;
  padding: (@baseline - 1) 20px @baseline 150px;
  border-top: 1px solid #ddd;
  .border-radius(0 0 3px 3px);
Mark Otto's avatar
Mark Otto committed
189
  .secondary-action {
Jacob Thornton's avatar
Jacob Thornton committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
    float: right;
    a {
      line-height: 30px;
      &:hover {
        text-decoration: underline;
      }
    }
  }
}

// Help Text
.help-inline,
.help-block {
  font-size: 12px;
  line-height: @baseline;
205
  color: @grayLight;
Jacob Thornton's avatar
Jacob Thornton committed
206
207
208
}
.help-inline {
  padding-left: 5px;
Jacob Thornton's avatar
Jacob Thornton committed
209
210
  *position: relative; /* IE6-7 */
  *top: -5px; /* IE6-7 */
Jacob Thornton's avatar
Jacob Thornton committed
211
}
212

Jacob Thornton's avatar
Jacob Thornton committed
213
214
215
216
217
218
219
// Big blocks of help text
.help-block {
  display: block;
  max-width: 600px;
}

// Inline Fields (input fields that appear as inline objects
Mark Otto's avatar
Mark Otto committed
220
.inline-inputs {
Jacob Thornton's avatar
Jacob Thornton committed
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
  color: @gray;
  span, input[type=text] {
    display: inline-block;
  }
  input.mini {
    width: 60px;
  }
  input.small {
    width: 90px;
  }
  span {
    padding: 0 2px 0 1px;
  }
}

// Allow us to put symbols and text within the input field for a cleaner look
Mark Otto's avatar
Mark Otto committed
237
238
.input-prepend,
.input-append {
Jacob Thornton's avatar
Jacob Thornton committed
239
240
241
242
243
244
245
246
247
  input[type=text] {
    .border-radius(0 3px 3px 0);
  }
  .add-on {
    background: #f5f5f5;
    float: left;
    display: block;
    width: auto;
    min-width: 16px;
248
    padding: 4px 4px 4px 5px;
249
    color: @grayLight;
Jacob Thornton's avatar
Jacob Thornton committed
250
251
252
253
254
    font-weight: normal;
    line-height: 18px;
    height: 18px;
    text-align: center;
    text-shadow: 0 1px 0 #fff;
255
    border: 1px solid #ccc;
Jacob Thornton's avatar
Jacob Thornton committed
256
257
258
259
260
261
262
263
    border-right-width: 0;
    .border-radius(3px 0 0 3px);
  }
  .active {
    background: lighten(@green, 30);
    border-color: @green;
  }
}
Jacob Thornton's avatar
Jacob Thornton committed
264

265
.input-prepend {
Jacob Thornton's avatar
Jacob Thornton committed
266
267
268
269
270
  .add-on {
    *margin-top: 1px; /* IE6-7 */
  }
}

Mark Otto's avatar
Mark Otto committed
271
.input-append {
Jacob Thornton's avatar
Jacob Thornton committed
272
273
274
275
276
277
278
279
280
281
282
283
  input[type=text] {
    float: left;
    .border-radius(3px 0 0 3px);
  }
  .add-on {
    .border-radius(0 3px 3px 0);
    border-right-width: 1px;
    border-left-width: 0;
  }
}

// Stacked options for forms (radio buttons or checkboxes)
Mark Otto's avatar
Mark Otto committed
284
.inputs-list {
Jacob Thornton's avatar
Jacob Thornton committed
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
  margin: 0 0 5px;
  width: 100%;
  li {
    display: block;
    padding: 0;
    width: 100%;
    label {
      display: block;
      float: none;
      width: auto;
      padding: 0;
      line-height: @baseline;
      text-align: left;
      white-space: normal;
      strong {
        color: @gray;
      }
      small {
        font-size: 12px;
304
        font-weight: normal;
Jacob Thornton's avatar
Jacob Thornton committed
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
      }
    }
    ul.inputs-list {
      margin-left: 25px;
      margin-bottom: 10px;
      padding-top: 0;
    }
    &:first-child {
      padding-top: 5px;
    }
  }
  input[type=radio],
  input[type=checkbox] {
    margin-bottom: 0;
  }
}

// Stacked forms
form.form-stacked {
324
  padding-left: 20px;
Jacob Thornton's avatar
Jacob Thornton committed
325
326
  fieldset {
    padding-top: @baseline / 2;
327
  }
Jacob Thornton's avatar
Jacob Thornton committed
328
329
330
331
332
333
334
335
336
337
338
339
  legend {
    margin-left: 0;
  }
  label {
    display: block;
    float: none;
    width: auto;
    font-weight: bold;
    text-align: left;
    line-height: 20px;
    padding-top: 0;
  }
Mark Otto's avatar
Mark Otto committed
340
  .clearfix {
Jacob Thornton's avatar
Jacob Thornton committed
341
342
343
344
345
    margin-bottom: @baseline / 2;
    div.input {
      margin-left: 0;
    }
  }
Mark Otto's avatar
Mark Otto committed
346
  .inputs-list {
Jacob Thornton's avatar
Jacob Thornton committed
347
348
349
350
351
352
353
354
355
    margin-bottom: 0;
    li {
      padding-top: 0;
      label {
        font-weight: normal;
        padding-top: 0;
      }
    }
  }
Mark Otto's avatar
Mark Otto committed
356
  div.error {
357
358
359
360
361
362
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 10px;
    margin-top: 0;
    margin-left: -10px;
  }
Mark Otto's avatar
Mark Otto committed
363
  .actions {
364
365
366
    margin-left: -20px;
    padding-left: 20px;
  }
Jacob Thornton's avatar
Jacob Thornton committed
367
}