mixins.less 22.2 KB
Newer Older
1
2
3
//
// Mixins
// --------------------------------------------------
4

5

6
7
// Utilities
// -------------------------
8
9

// Clearfix
10
11
12
13
14
15
16
17
18
// Source: http://nicolasgallagher.com/micro-clearfix-hack/
//
// For modern browsers
// 1. The space content is one way to avoid an Opera bug when the
//    contenteditable attribute is included anywhere else in the document.
//    Otherwise it causes space to appear at the top and bottom of elements
//    that are clearfixed.
// 2. The use of `table` rather than `block` is only necessary if using
//    `:before` to contain the top-margins of child elements.
19
.clearfix() {
20
  &:before,
21
  &:after {
22
23
    content: " "; /* 1 */
    display: table; /* 2 */
24
25
  }
  &:after {
26
    clear: both;
27
  }
28
29
}

Mark Otto's avatar
Mark Otto committed
30
31
32
// Webkit-style focus
.tab-focus() {
  // Default
33
  outline: thin dotted #333;
Mark Otto's avatar
Mark Otto committed
34
35
36
37
38
  // Webkit
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
}

39
// Center-align a block level element
40
.center-block() {
41
  display: block;
42
43
  margin-left: auto;
  margin-right: auto;
44
45
46
}

// Sizing shortcuts
47
.size(@width; @height) {
48
  width: @width;
49
  height: @height;
50
}
51
.square(@size) {
52
  .size(@size; @size);
53
54
}

55
// Placeholder text
Mark Otto's avatar
Mark Otto committed
56
.placeholder(@color: @input-color-placeholder) {
57
58
59
60
  &:-moz-placeholder            { color: @color; } // Firefox 4-18
  &::-moz-placeholder           { color: @color; } // Firefox 19+
  &:-ms-input-placeholder       { color: @color; } // Internet Explorer 10+
  &::-webkit-input-placeholder  { color: @color; } // Safari and Chrome
61
62
}

Mark Otto's avatar
Mark Otto committed
63
64
65
66
67
68
69
70
// Text overflow
// Requires inline-block or block for proper styling
.text-overflow() {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

71
72
// CSS image replacement
// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
73
.hide-text() {
74
  font: ~"0/0" a;
75
  color: transparent;
76
  text-shadow: none;
77
  background-color: transparent;
78
  border: 0;
79
}
80

81

82

83
84
85
// CSS3 PROPERTIES
// --------------------------------------------------

86
// Single side border-radius
87
.border-top-radius(@radius) {
88
89
  border-top-right-radius: @radius;
   border-top-left-radius: @radius;
90
91
}
.border-right-radius(@radius) {
92
93
  border-bottom-right-radius: @radius;
     border-top-right-radius: @radius;
Mark Otto's avatar
Mark Otto committed
94
95
}
.border-bottom-radius(@radius) {
96
97
  border-bottom-right-radius: @radius;
   border-bottom-left-radius: @radius;
Mark Otto's avatar
Mark Otto committed
98
99
}
.border-left-radius(@radius) {
100
101
  border-bottom-left-radius: @radius;
     border-top-left-radius: @radius;
102
103
}

104
// Drop shadows
Mark Otto's avatar
Mark Otto committed
105
.box-shadow(@shadow) {
106
  -webkit-box-shadow: @shadow; // iOS <4.3 & Android <4.1
107
          box-shadow: @shadow;
108
109
110
}

// Transitions
Mark Otto's avatar
Mark Otto committed
111
112
113
.transition(@transition) {
  -webkit-transition: @transition;
          transition: @transition;
114
}
Tunghsiao Liu's avatar
Tunghsiao Liu committed
115
116
117
118
.transition-delay(@transition-delay) {
  -webkit-transition-delay: @transition-delay;
          transition-delay: @transition-delay;
}
Tunghsiao Liu's avatar
Tunghsiao Liu committed
119
120
121
122
.transition-duration(@transition-duration) {
  -webkit-transition-duration: @transition-duration;
          transition-duration: @transition-duration;
}
123
124
125
126
127
128
.transition-transform(@transition) {
  -webkit-transition: -webkit-transform @transition;
     -moz-transition: -moz-transform @transition;
       -o-transition: -o-transform @transition;
          transition: transform @transition;
}
129

Mark Otto's avatar
Mark Otto committed
130
// Transformations
131
.rotate(@degrees) {
132
  -webkit-transform: rotate(@degrees);
133
      -ms-transform: rotate(@degrees); // IE9+
134
135
          transform: rotate(@degrees);
}
136
137
.scale(@ratio) {
  -webkit-transform: scale(@ratio);
138
      -ms-transform: scale(@ratio); // IE9+
139
          transform: scale(@ratio);
140
}
141
.translate(@x; @y) {
Mark Otto's avatar
Mark Otto committed
142
  -webkit-transform: translate(@x, @y);
143
      -ms-transform: translate(@x, @y); // IE9+
Mark Otto's avatar
Mark Otto committed
144
145
          transform: translate(@x, @y);
}
146
.skew(@x; @y) {
Mark Otto's avatar
Mark Otto committed
147
  -webkit-transform: skew(@x, @y);
148
      -ms-transform: skewX(@x) skewY(@y); // See https://github.com/twbs/bootstrap/issues/4885; IE9+
Mark Otto's avatar
Mark Otto committed
149
150
          transform: skew(@x, @y);
}
151
.translate3d(@x; @y; @z) {
152
153
  -webkit-transform: translate3d(@x, @y, @z);
          transform: translate3d(@x, @y, @z);
154
}
155

156
157
// Backface visibility
// Prevent browsers from flickering when using CSS 3D transforms.
Chris Rebert's avatar
Chris Rebert committed
158
// Default value is `visible`, but can be changed to `hidden`
159
// See git pull https://github.com/dannykeane/bootstrap.git backface-visibility for examples
160
.backface-visibility(@visibility){
161
162
163
  -webkit-backface-visibility: @visibility;
     -moz-backface-visibility: @visibility;
          backface-visibility: @visibility;
164
165
}

166
167
168
169
170
171
172
// Box sizing
.box-sizing(@boxmodel) {
  -webkit-box-sizing: @boxmodel;
     -moz-box-sizing: @boxmodel;
          box-sizing: @boxmodel;
}

173
174
175
176
177
// User select
// For selecting text on the page
.user-select(@select) {
  -webkit-user-select: @select;
     -moz-user-select: @select;
178
      -ms-user-select: @select; // IE10+
179
180
181
182
       -o-user-select: @select;
          user-select: @select;
}

183
// Resize anything
184
.resizable(@direction) {
185
186
187
188
  resize: @direction; // Options: horizontal, vertical, both
  overflow: auto; // Safari fix
}

189
// CSS3 Content Columns
190
.content-columns(@column-count; @column-gap: @grid-gutter-width) {
191
192
193
194
195
196
  -webkit-column-count: @column-count;
     -moz-column-count: @column-count;
          column-count: @column-count;
  -webkit-column-gap: @column-gap;
     -moz-column-gap: @column-gap;
          column-gap: @column-gap;
197
198
}

Synchro's avatar
Synchro committed
199
200
// Optional hyphenation
.hyphens(@mode: auto) {
Mark Otto's avatar
Mark Otto committed
201
  word-wrap: break-word;
Synchro's avatar
Synchro committed
202
203
  -webkit-hyphens: @mode;
     -moz-hyphens: @mode;
204
      -ms-hyphens: @mode; // IE10+
Synchro's avatar
Synchro committed
205
       -o-hyphens: @mode;
Synchro's avatar
Synchro committed
206
207
208
          hyphens: @mode;
}

209
// Opacity
210
.opacity(@opacity) {
211
212
  opacity: @opacity;
  // IE8 filter
213
  @opacity-ie: (@opacity * 100);
214
  filter: ~"alpha(opacity=@{opacity-ie})";
215
216
217
218
}



Mark Otto's avatar
Mark Otto committed
219
// GRADIENTS
220
221
// --------------------------------------------------

222
#gradient {
Mark Otto's avatar
Mark Otto committed
223
224
225
226
227

  // Horizontal gradient, from left to right
  //
  // Creates two color stops, start and end, by specifying a color and position for each color stop.
  // Color stops are not available in IE9 and below.
228
  .horizontal(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
Mark Otto's avatar
Mark Otto committed
229
230
231
232
    background-image: -webkit-gradient(linear, @start-percent top, @end-percent top, from(@start-color), to(@end-color)); // Safari 4+, Chrome 2+
    background-image: -webkit-linear-gradient(left, color-stop(@start-color @start-percent), color-stop(@end-color @end-percent)); // Safari 5.1+, Chrome 10+
    background-image: -moz-linear-gradient(left, @start-color @start-percent, @end-color @end-percent); // FF 3.6+
    background-image:  linear-gradient(to right, @start-color @start-percent, @end-color @end-percent); // Standard, IE10
233
    background-repeat: repeat-x;
Mark Otto's avatar
Mark Otto committed
234
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@start-color),argb(@end-color))); // IE9 and down
235
  }
Mark Otto's avatar
Mark Otto committed
236
237
238
239
240

  // Vertical gradient, from top to bottom
  //
  // Creates two color stops, start and end, by specifying a color and position for each color stop.
  // Color stops are not available in IE9 and below.
241
  .vertical(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
Mark Otto's avatar
Mark Otto committed
242
243
244
245
    background-image: -webkit-gradient(linear, left @start-percent, left @end-percent, from(@start-color), to(@end-color)); // Safari 4+, Chrome 2+
    background-image: -webkit-linear-gradient(top, @start-color, @start-percent, @end-color, @end-percent); // Safari 5.1+, Chrome 10+
    background-image:  -moz-linear-gradient(top, @start-color @start-percent, @end-color @end-percent); // FF 3.6+
    background-image: linear-gradient(to bottom, @start-color @start-percent, @end-color @end-percent); // Standard, IE10
246
    background-repeat: repeat-x;
Mark Otto's avatar
Mark Otto committed
247
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@start-color),argb(@end-color))); // IE9 and down
248
  }
Mark Otto's avatar
Mark Otto committed
249

250
  .directional(@start-color: #555; @end-color: #333; @deg: 45deg) {
251
    background-repeat: repeat-x;
Mark Otto's avatar
Mark Otto committed
252
253
254
    background-image: -webkit-linear-gradient(@deg, @start-color, @end-color); // Safari 5.1+, Chrome 10+
    background-image: -moz-linear-gradient(@deg, @start-color, @end-color); // FF 3.6+
    background-image: linear-gradient(@deg, @start-color, @end-color); // Standard, IE10
255
  }
256
  .horizontal-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
Mark Otto's avatar
Mark Otto committed
257
258
259
260
    background-image: -webkit-gradient(left, linear, 0 0, 0 100%, from(@start-color), color-stop(@color-stop, @mid-color), to(@end-color));
    background-image: -webkit-linear-gradient(left, @start-color, @mid-color @color-stop, @end-color);
    background-image: -moz-linear-gradient(left, @start-color, @mid-color @color-stop, @end-color);
    background-image: linear-gradient(to right, @start-color, @mid-color @color-stop, @end-color);
Francisco arenas's avatar
Francisco arenas committed
261
    background-repeat: no-repeat;
Mark Otto's avatar
Mark Otto committed
262
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@start-color),argb(@end-color))); // IE9 and down, gets no color-stop at all for proper fallback
Francisco arenas's avatar
Francisco arenas committed
263
  }
264
  .vertical-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
Mark Otto's avatar
Mark Otto committed
265
266
267
268
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@start-color), color-stop(@color-stop, @mid-color), to(@end-color));
    background-image: -webkit-linear-gradient(@start-color, @mid-color @color-stop, @end-color);
    background-image: -moz-linear-gradient(top, @start-color, @mid-color @color-stop, @end-color);
    background-image: linear-gradient(@start-color, @mid-color @color-stop, @end-color);
269
    background-repeat: no-repeat;
Mark Otto's avatar
Mark Otto committed
270
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@start-color),argb(@end-color))); // IE9 and down, gets no color-stop at all for proper fallback
271
  }
272
  .radial(@inner-color: #555; @outer-color: #333) {
Mark Otto's avatar
Mark Otto committed
273
274
275
276
    background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(@inner-color), to(@outer-color));
    background-image: -webkit-radial-gradient(circle, @inner-color, @outer-color);
    background-image: -moz-radial-gradient(circle, @inner-color, @outer-color);
    background-image: radial-gradient(circle, @inner-color, @outer-color);
277
278
    background-repeat: no-repeat;
  }
279
  .striped(@color: #555; @angle: 45deg) {
280
281
282
283
    background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255,255,255,.15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255,255,255,.15)), color-stop(.75, rgba(255,255,255,.15)), color-stop(.75, transparent), to(transparent));
    background-image: -webkit-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
    background-image: -moz-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
    background-image: linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
Piotrek Okoński's avatar
Piotrek Okoński committed
284
  }
285
}
Mark Otto's avatar
Mark Otto committed
286

287
// Reset filters for IE
Mark Otto's avatar
Mark Otto committed
288
289
290
//
// When you need to remove a gradient background, don't forget to use this to reset
// the IE filter for IE9 and below.
291
.reset-filter() {
292
  filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
293
}
294

295

Mark Otto's avatar
Mark Otto committed
296

297
298
// Retina images
//
Mark Otto's avatar
Mark Otto committed
299
// Short retina mixin for setting background-image and -size
300

301
.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
Mark Otto's avatar
Mark Otto committed
302
303
304
305
306
307
308
309
310
311
312
313
  background-image: url("@{file-1x}");

  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and (     -o-min-device-pixel-ratio: 2/1),
  only screen and (        min-device-pixel-ratio: 2),
  only screen and (                min-resolution: 192dpi),
  only screen and (                min-resolution: 2dppx) {
    background-image: url("@{file-2x}");
    background-size: @width-1x @height-1x;
  }
Danny Keane's avatar
Danny Keane committed
314
315
}

316

317
318
319
320
321
322
323
324
325
326
327
// Responsive image
//
// Keep images from scaling beyond the width of their parents.

.img-responsive(@display: block;) {
  display: @display;
  max-width: 100%; // Part 1: Set a maximum relative to the parent
  height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching
}


328
329
330
// COMPONENT MIXINS
// --------------------------------------------------

331
// Horizontal dividers
332
333
// -------------------------
// Dividers (basically an hr) within dropdowns and nav lists
Mark Otto's avatar
Mark Otto committed
334
335
.nav-divider(@color: #e5e5e5) {
  height: 1px;
336
  margin: ((@line-height-computed / 2) - 1) 0;
Jacob Thornton's avatar
Jacob Thornton committed
337
  overflow: hidden;
Mark Otto's avatar
Mark Otto committed
338
  background-color: @color;
339
340
}

341
342
343
344
// Panels
// -------------------------
.panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) {
  border-color: @border;
345
  & > .panel-heading {
346
347
348
    color: @heading-text-color;
    background-color: @heading-bg-color;
    border-color: @heading-border;
Mark Otto's avatar
Mark Otto committed
349
350
351
352
    + .panel-collapse .panel-body {
      border-top-color: @border;
    }
  }
353
  & > .panel-footer {
Mark Otto's avatar
Mark Otto committed
354
355
356
    + .panel-collapse .panel-body {
      border-bottom-color: @border;
    }
357
358
359
  }
}

Chris Rebert's avatar
Chris Rebert committed
360
361
// Alerts
// -------------------------
362
.alert-variant(@background; @border; @text-color) {
Chris Rebert's avatar
Chris Rebert committed
363
364
365
366
367
368
369
370
371
372
373
  background-color: @background;
  border-color: @border;
  color: @text-color;
  hr {
    border-top-color: darken(@border, 5%);
  }
  .alert-link {
    color: darken(@text-color, 10%);
  }
}

ggam's avatar
ggam committed
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
// Tables
// -------------------------
.table-row-variant(@state; @background; @border) {
  // Exact selectors below required to override `.table-striped` and prevent
  // inheritance to nested tables.
  .table > thead > tr,
  .table > tbody > tr,
  .table > tfoot > tr {
    > td.@{state},
    > th.@{state},
    &.@{state} > td,
    &.@{state} > th {
      background-color: @background;
      border-color: @border;
    }
  }
390

ggam's avatar
ggam committed
391
392
393
394
395
396
397
398
399
400
401
402
  // Hover states for `.table-hover`
  // Note: this is not available for cells or rows within `thead` or `tfoot`.
  .table-hover > tbody > tr {
    > td.@{state}:hover,
    > th.@{state}:hover,
    &.@{state}:hover > td {
      background-color: darken(@background, 5%);
      border-color: darken(@border, 5%);
    }
  }
}

403
// Button variants
404
405
406
// -------------------------
// Easily pump out default styles, as well as :hover, :focus, :active,
// and disabled options for all buttons
407
.button-variant(@color; @background; @border) {
408
  color: @color;
409
410
  background-color: @background;
  border-color: @border;
411

Mark Otto's avatar
Mark Otto committed
412
  &:hover,
413
  &:focus,
414
  &:active,
415
416
  &.active,
  .open .dropdown-toggle& {
417
    color: @color;
418
419
    background-color: darken(@background, 8%);
        border-color: darken(@border, 12%);
Mark Otto's avatar
Mark Otto committed
420
  }
421
422
423
424
425
  &:active,
  &.active,
  .open .dropdown-toggle& {
    background-image: none;
  }
426
  &.disabled,
427
  &[disabled],
428
  fieldset[disabled] & {
429
    &,
430
431
    &:hover,
    &:focus,
432
433
    &:active,
    &.active {
434
435
436
      background-color: @background;
          border-color: @border
    }
437
438
439
  }
}

ggam's avatar
ggam committed
440
441
442
443
444
445
446
447
448
// Button sizes
// -------------------------
.button-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
  padding: @padding-vertical @padding-horizontal;
  font-size: @font-size;
  line-height: @line-height;
  border-radius: @border-radius;
}

ggam's avatar
ggam committed
449
450
// Pagination
// -------------------------
Guillermo González de Agüero's avatar
Guillermo González de Agüero committed
451
.pagination-size(@padding-vertical; @padding-horizontal; @font-size; @border-radius) {
ggam's avatar
ggam committed
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
  > li {
    > a,
    > span {
      padding: @padding-vertical @padding-horizontal;
      font-size: @font-size;
    }
    &:first-child {
      > a,
      > span {
        .border-left-radius(@border-radius);
      }
    }
    &:last-child {
      > a,
      > span {
        .border-right-radius(@border-radius);
      }
    }
  }
}

Chris Rebert's avatar
Chris Rebert committed
473
474
475
476
477
478
479
480
481
482
483
484
// Labels
// -------------------------
.label-variant(@color) {
  background-color: @color;
  &[href] {
    &:hover,
    &:focus {
      background-color: darken(@color, 10%);
    }
  }
}

485
486
487
// Navbar vertical align
// -------------------------
// Vertically center elements in the navbar.
488
// Example: an element has a height of 30px, so write out `.navbar-vertical-align(30px);` to calculate the appropriate top margin.
Mark Otto's avatar
Mark Otto committed
489
.navbar-vertical-align(@element-height) {
490
491
  margin-top: ((@navbar-height - @element-height) / 2);
  margin-bottom: ((@navbar-height - @element-height) / 2);
492
493
}

494
495
496
497
498
499
500
501
502
// Progress bars
// -------------------------
.progress-bar-variant(@color) {
  background-color: @color;
  .progress-striped & {
    #gradient > .striped(@color);
  }
}

Mark Otto's avatar
Mark Otto committed
503
504
505
506
507
508
509
510
511
512
// Responsive utilities
// -------------------------
// More easily include all the states for responsive-utilities.less.
.responsive-visibility() {
  display: block !important;
  tr& { display: table-row !important; }
  th&,
  td& { display: table-cell !important; }
}

513
514
515
516
517
518
519
.responsive-invisibility() {
  display: none !important;
  tr& { display: none !important; }
  th&,
  td& { display: none !important; }
}

520
521
522
// Grid System
// -----------

523
// Centered container element
524
525
.container-fixed() {
  margin-right: auto;
Jacob Thornton's avatar
Jacob Thornton committed
526
  margin-left: auto;
527
  .clearfix();
528
529
}

530
// Creates a wrapper for a series of columns
531
.make-row(@gutter: @grid-gutter-width) {
532
  // Then clear the floated columns
533
  .clearfix();
534

535
536
537
538
539
  .container & {
    @media (min-width: @screen-small) {
      margin-left:  (@gutter / -2);
      margin-right: (@gutter / -2);
    }
Mark Otto's avatar
Mark Otto committed
540
541
  }

542
543
  // Negative margin nested rows out to align the content of columns
  .row {
544
545
    margin-left:  (@gutter / -2);
    margin-right: (@gutter / -2);
546
  }
547
}
Mark Otto's avatar
Mark Otto committed
548

549
550
// Generate the extra small columns
.make-xs-column(@columns; @gutter: @grid-gutter-width) {
551
552
  position: relative;
  float: left;
553
  width: percentage((@columns / @grid-columns));
554
555
556
557
558
559
560
561
  // Prevent columns from collapsing when empty
  min-height: 1px;
  // Inner gutter via padding
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
}

// Generate the small columns
562
.make-sm-column(@columns; @gutter: @grid-gutter-width) {
563
  position: relative;
564
565
  // Prevent columns from collapsing when empty
  min-height: 1px;
566
  // Inner gutter via padding
567
568
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
569
570

  // Calculate width based on number of columns available
571
  @media (min-width: @screen-small) {
572
    float: left;
573
574
    width: percentage((@columns / @grid-columns));
  }
575
}
Mark Otto's avatar
Mark Otto committed
576

577
// Generate the small column offsets
578
.make-sm-column-offset(@columns) {
579
  @media (min-width: @screen-small) {
580
581
582
    margin-left: percentage((@columns / @grid-columns));
  }
}
583
.make-sm-column-push(@columns) {
584
  @media (min-width: @screen-small) {
585
586
587
    left: percentage((@columns / @grid-columns));
  }
}
588
.make-sm-column-pull(@columns) {
589
  @media (min-width: @screen-small) {
590
591
    right: percentage((@columns / @grid-columns));
  }
592
}
593

594
595
// Generate the medium columns
.make-md-column(@columns; @gutter: @grid-gutter-width) {
Bass Jobsen's avatar
Bass Jobsen committed
596
597
598
599
  position: relative;
  // Prevent columns from collapsing when empty
  min-height: 1px;
  // Inner gutter via padding
600
601
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
Mark Otto's avatar
Mark Otto committed
602

Bass Jobsen's avatar
Bass Jobsen committed
603
  // Calculate width based on number of columns available
604
605
  @media (min-width: @screen-medium) {
    float: left;
Bass Jobsen's avatar
Bass Jobsen committed
606
607
608
    width: percentage((@columns / @grid-columns));
  }
}
Mark Otto's avatar
Mark Otto committed
609

610
// Generate the large column offsets
611
.make-md-column-offset(@columns) {
612
613
614
615
  @media (min-width: @screen-medium) {
    margin-left: percentage((@columns / @grid-columns));
  }
}
616
.make-md-column-push(@columns) {
617
618
619
620
  @media (min-width: @screen-medium) {
    left: percentage((@columns / @grid-columns));
  }
}
621
.make-md-column-pull(@columns) {
622
623
624
625
626
  @media (min-width: @screen-medium) {
    right: percentage((@columns / @grid-columns));
  }
}

627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
// Generate the large columns
.make-lg-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  // Prevent columns from collapsing when empty
  min-height: 1px;
  // Inner gutter via padding
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);

  // Calculate width based on number of columns available
  @media (min-width: @screen-large) {
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}

// Generate the large column offsets
.make-lg-column-offset(@columns) {
  @media (min-width: @screen-large) {
    margin-left: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-push(@columns) {
  @media (min-width: @screen-large) {
    left: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-pull(@columns) {
  @media (min-width: @screen-large) {
    right: percentage((@columns / @grid-columns));
  }
}

Mark Otto's avatar
Mark Otto committed
660

Mark Otto's avatar
Mark Otto committed
661
662
663
664
665
// Form validation states
//
// Used in forms.less to generate the form validation CSS for warnings, errors,
// and successes.

666
.form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) {
Mark Otto's avatar
Mark Otto committed
667
  // Color the label and help text
668
  .help-block,
Mark Otto's avatar
Mark Otto committed
669
670
671
672
  .control-label {
    color: @text-color;
  }
  // Set the border and box shadow on specific inputs to match
Mark Otto's avatar
Mark Otto committed
673
  .form-control {
Mark Otto's avatar
Mark Otto committed
674
675
676
677
678
679
680
681
    border-color: @border-color;
    .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work
    &:focus {
      border-color: darken(@border-color, 10%);
      @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@border-color, 20%);
      .box-shadow(@shadow);
    }
  }
682
683
684
685
686
  // Set validation states also for addons
  .input-group-addon {
    color: @text-color;
    border-color: @border-color;
    background-color: @background-color;
Mark Otto's avatar
Mark Otto committed
687
  }
Mark Otto's avatar
Mark Otto committed
688
}
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710

// Form control focus state
//
// Generate a customized focus state and for any input with the specified color,
// which defaults to the `@input-focus-border` variable.
//
// We highly encourage you to not customize the default value, but instead use
// this to tweak colors on an as-needed basis. This aesthetic change is based on
// WebKit's default styles, but applicable to a wider range of browsers. Its
// usability and accessibility should be taken into account with any change.
//
// Example usage: change the default blue border and shadow to white for better
// contrast against a dark gray background.

.form-control-focus(@color: @input-border-focus) {
  @color-rgba: rgba(red(@color), green(@color), blue(@color), .6);
  &:focus {
    border-color: @color;
    outline: 0;
    .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}");
  }
}
ggam's avatar
ggam committed
711
712
713
714
715
716
717
718
719
720
721
722
723

// Form control sizing
//
// Relative text size, padding, and border-radii changes for form controls. For
// horizontal sizing, wrap controls in the predefined grid classes. `<select>`
// element gets special love because it's special, and that's a fact!

.input-size(@input-height; @padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
  height: @input-height;
  padding: @padding-vertical @padding-horizontal;
  font-size: @font-size;
  line-height: @line-height;
  border-radius: @border-radius;
724

ggam's avatar
ggam committed
725
726
727
728
  select& {
    height: @input-height;
    line-height: @input-height;
  }
729

ggam's avatar
ggam committed
730
731
732
733
  textarea& {
    height: auto;
  }
}