mixins.less 31.8 KB
Newer Older
1
2
3
//
// Mixins
// --------------------------------------------------
Mark Otto's avatar
Mark Otto committed
4
5
6


// Table of Contents
7
//
Mark Otto's avatar
Mark Otto committed
8
// Utilities
9
10
11
12
13
14
15
16
17
// - Clearfix
// - WebKit-style focus
// - Center-align a block level element
// - Sizing shortcuts
// - Placeholder text
// - Text overflow
// - Requires inline-block or block for proper styling
// - CSS image replacement
//
Mark Otto's avatar
Mark Otto committed
18
// CSS3 properties
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// - Single side border-radius
// - Drop shadows
// - Transitions
// - Transformations
// - Animations
// - Backface visibility
// - Prevent browsers from flickering when using CSS 3D transforms.
// - Box sizing
// - User select
// - For selecting text on the page
// - Resize anything
// - CSS3 Content Columns
// - Optional hyphenation
// - Opacity
//
Mark Otto's avatar
Mark Otto committed
34
// Gradients
35
36
37
38
// - Reset filters for IE
// - Retina images
// - Responsive image
//
Mark Otto's avatar
Mark Otto committed
39
// Component mixins
40
41
42
43
44
45
46
47
48
49
50
51
52
// - Horizontal dividers
// - Dividers (basically an hr) within dropdowns and nav lists
// - Panels
// - Alerts
// - Tables
// - List Groups
// - Button variants
// - Button sizes
// - Pagination
// - Labels
// - Contextual backgrounds
// - Typography
// - Navbar vertical align
53
// - Vertically center elements in the navbar
54
55
// - Progress bars
//
Mark Otto's avatar
Mark Otto committed
56
57
58
59
60
61
62
// Responsive utilities
//
// Forms
// - Form control focus state
// - Form control sizing
//
// Grid system
63
64
65
66
67
// - Centered container element
// - Generate the extra small columns
// - Generate the small columns
// - Generate the medium columns
// - Generate the large columns
Mark Otto's avatar
Mark Otto committed
68
69
//
// Framework grid generation
70
// - Loop to generate grid all grid classes
71
72
// - Form validation states
// - Form control focus state
73

74

Mark Otto's avatar
Mark Otto committed
75

76
// Utilities
Mark Otto's avatar
Mark Otto committed
77
// --------------------------------------------------
78
79

// Clearfix
80
81
82
83
84
85
86
87
88
// 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.
89
.clearfix() {
90
  &:before,
91
  &:after {
92
93
    content: " "; // 1
    display: table; // 2
94
95
  }
  &:after {
96
    clear: both;
97
  }
98
99
}

Chris Rebert's avatar
Chris Rebert committed
100
// WebKit-style focus
Mark Otto's avatar
Mark Otto committed
101
102
.tab-focus() {
  // Default
103
  outline: thin dotted;
104
  // WebKit
Mark Otto's avatar
Mark Otto committed
105
106
107
108
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
}

109
// Center-align a block level element
110
.center-block() {
111
  display: block;
112
113
  margin-left: auto;
  margin-right: auto;
114
115
116
}

// Sizing shortcuts
117
.size(@width; @height) {
118
  width: @width;
119
  height: @height;
120
}
121
.square(@size) {
122
  .size(@size; @size);
123
124
}

125
// Placeholder text
Mark Otto's avatar
Mark Otto committed
126
.placeholder(@color: @input-color-placeholder) {
127
  &::-moz-placeholder           { color: @color;   // Firefox
128
                                  opacity: 1; } // See https://github.com/twbs/bootstrap/pull/11526
129
130
  &:-ms-input-placeholder       { color: @color; } // Internet Explorer 10+
  &::-webkit-input-placeholder  { color: @color; } // Safari and Chrome
131
132
}

Mark Otto's avatar
Mark Otto committed
133
134
135
136
137
138
139
140
// Text overflow
// Requires inline-block or block for proper styling
.text-overflow() {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

141
// CSS image replacement
142
143
144
//
// Heads up! v3 launched with with only `.hide-text()`, but per our pattern for
// mixins being reused as classes with the same name, this doesn't hold up. As
Zlatan Vasović's avatar
Zlatan Vasović committed
145
// of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`.
146
//
147
// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
148

149
150
151
152
153
154
155
156
157
// Deprecated as of v3.0.1 (will be removed in v4)
.hide-text() {
  font: ~"0/0" a;
  color: transparent;
  text-shadow: none;
  background-color: transparent;
  border: 0;
}
// New mixin to use as of v3.0.1
158
.text-hide() {
159
  .hide-text();
160
}
161

162

163

Mark Otto's avatar
Mark Otto committed
164
// CSS3 properties
165
166
// --------------------------------------------------

167
// Single side border-radius
168
.border-top-radius(@radius) {
169
170
  border-top-right-radius: @radius;
   border-top-left-radius: @radius;
171
172
}
.border-right-radius(@radius) {
173
174
  border-bottom-right-radius: @radius;
     border-top-right-radius: @radius;
Mark Otto's avatar
Mark Otto committed
175
176
}
.border-bottom-radius(@radius) {
177
178
  border-bottom-right-radius: @radius;
   border-bottom-left-radius: @radius;
Mark Otto's avatar
Mark Otto committed
179
180
}
.border-left-radius(@radius) {
181
182
  border-bottom-left-radius: @radius;
     border-top-left-radius: @radius;
183
184
}

185
// Drop shadows
186
187
188
189
//
// Note: Deprecated `.box-shadow()` as of v3.1.0 since all of Bootstrap's
//   supported browsers that have box shadow capabilities now support the
//   standard `box-shadow` property.
Mark Otto's avatar
Mark Otto committed
190
.box-shadow(@shadow) {
191
  -webkit-box-shadow: @shadow; // iOS <4.3 & Android <4.1
192
          box-shadow: @shadow;
193
194
195
}

// Transitions
Bas Bosman's avatar
Bas Bosman committed
196
197
//
// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Mark Otto's avatar
Mark Otto committed
198
199
.transition(@transition) {
  -webkit-transition: @transition;
Bas Bosman's avatar
Bas Bosman committed
200
       -o-transition: @transition;
Mark Otto's avatar
Mark Otto committed
201
          transition: @transition;
202
}
Bas Bosman's avatar
Bas Bosman committed
203
204

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
205
206
207
208
.transition-property(@transition-property) {
  -webkit-transition-property: @transition-property;
          transition-property: @transition-property;
}
Bas Bosman's avatar
Bas Bosman committed
209
210

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Tunghsiao Liu's avatar
Tunghsiao Liu committed
211
212
213
214
.transition-delay(@transition-delay) {
  -webkit-transition-delay: @transition-delay;
          transition-delay: @transition-delay;
}
Bas Bosman's avatar
Bas Bosman committed
215
216

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Tunghsiao Liu's avatar
Tunghsiao Liu committed
217
218
219
220
.transition-duration(@transition-duration) {
  -webkit-transition-duration: @transition-duration;
          transition-duration: @transition-duration;
}
Bas Bosman's avatar
Bas Bosman committed
221
222

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
223
.transition-timing-function(@timing-function) {
Bas Bosman's avatar
Bas Bosman committed
224
225
  -webkit-transition-timing-function: @timing-function;
          transition-timing-function: @timing-function;
226
}
Bas Bosman's avatar
Bas Bosman committed
227
228

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
229
230
231
232
233
234
.transition-transform(@transition) {
  -webkit-transition: -webkit-transform @transition;
     -moz-transition: -moz-transform @transition;
       -o-transition: -o-transform @transition;
          transition: transform @transition;
}
235

Mark Otto's avatar
Mark Otto committed
236
// Transformations
Bas Bosman's avatar
Bas Bosman committed
237
238
//
// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
239
240
241
.scale(@ratio) {
  -webkit-transform: scale(@ratio);
      -ms-transform: scale(@ratio); // IE9 only
Bas Bosman's avatar
Bas Bosman committed
242
       -o-transform: scale(@ratio);
243
244
          transform: scale(@ratio);
}
Bas Bosman's avatar
Bas Bosman committed
245
246

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
247
248
249
.scale(@ratioX; @ratioY) {
  -webkit-transform: scale(@ratioX, @ratioY);
      -ms-transform: scale(@ratioX, @ratioY); // IE9 only
Bas Bosman's avatar
Bas Bosman committed
250
       -o-transform: scale(@ratioX, @ratioY);
251
252
          transform: scale(@ratioX, @ratioY);
}
Bas Bosman's avatar
Bas Bosman committed
253
254

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
255
256
257
.scaleX(@ratio) {
  -webkit-transform: scaleX(@ratio);
      -ms-transform: scaleX(@ratio); // IE9 only
Bas Bosman's avatar
Bas Bosman committed
258
       -o-transform: scaleX(@ratio);
259
260
          transform: scaleX(@ratio);
}
Bas Bosman's avatar
Bas Bosman committed
261
262

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
263
264
265
.scaleY(@ratio) {
  -webkit-transform: scaleY(@ratio);
      -ms-transform: scaleY(@ratio); // IE9 only
Bas Bosman's avatar
Bas Bosman committed
266
       -o-transform: scaleY(@ratio);
267
          transform: scaleY(@ratio);
268
}
Bas Bosman's avatar
Bas Bosman committed
269
270

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
271
272
273
.skew(@x; @y) {
  -webkit-transform: skew(@x, @y);
      -ms-transform: skewX(@x) skewY(@y); // See https://github.com/twbs/bootstrap/issues/4885; IE9+
Bas Bosman's avatar
Bas Bosman committed
274
       -o-transform: skew(@x, @y);
275
          transform: skew(@x, @y);
276
}
Bas Bosman's avatar
Bas Bosman committed
277
278

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
279
.translate(@x; @y) {
Mark Otto's avatar
Mark Otto committed
280
  -webkit-transform: translate(@x, @y);
281
      -ms-transform: translate(@x, @y); // IE9 only
Bas Bosman's avatar
Bas Bosman committed
282
       -o-transform: translate(@x, @y);
Mark Otto's avatar
Mark Otto committed
283
284
          transform: translate(@x, @y);
}
Bas Bosman's avatar
Bas Bosman committed
285
286

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
287
.translate3d(@x; @y; @z) {
288
289
  -webkit-transform: translate3d(@x, @y, @z);
          transform: translate3d(@x, @y, @z);
290
}
Bas Bosman's avatar
Bas Bosman committed
291
292

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
293
294
295
.rotate(@degrees) {
  -webkit-transform: rotate(@degrees);
      -ms-transform: rotate(@degrees); // IE9 only
Bas Bosman's avatar
Bas Bosman committed
296
       -o-transform: rotate(@degrees);
297
298
          transform: rotate(@degrees);
}
Bas Bosman's avatar
Bas Bosman committed
299
300

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
301
302
.rotateX(@degrees) {
  -webkit-transform: rotateX(@degrees);
303
      -ms-transform: rotateX(@degrees); // IE9 only
Bas Bosman's avatar
Bas Bosman committed
304
       -o-transform: rotateX(@degrees);
305
306
          transform: rotateX(@degrees);
}
Bas Bosman's avatar
Bas Bosman committed
307
308

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
309
310
.rotateY(@degrees) {
  -webkit-transform: rotateY(@degrees);
311
      -ms-transform: rotateY(@degrees); // IE9 only
Bas Bosman's avatar
Bas Bosman committed
312
       -o-transform: rotateY(@degrees);
313
314
          transform: rotateY(@degrees);
}
Bas Bosman's avatar
Bas Bosman committed
315
316

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
317
318
319
320
321
.perspective(@perspective) {
  -webkit-perspective: @perspective;
     -moz-perspective: @perspective;
          perspective: @perspective;
}
Bas Bosman's avatar
Bas Bosman committed
322
323

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
324
325
326
327
328
.perspective-origin(@perspective) {
  -webkit-perspective-origin: @perspective;
     -moz-perspective-origin: @perspective;
          perspective-origin: @perspective;
}
Bas Bosman's avatar
Bas Bosman committed
329
330

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Zlatan Vasović's avatar
Zlatan Vasović committed
331
.transform-origin(@origin) {
332
333
  -webkit-transform-origin: @origin;
     -moz-transform-origin: @origin;
334
      -ms-transform-origin: @origin; // IE9 only
335
336
337
          transform-origin: @origin;
}

Zlatan Vasović's avatar
Zlatan Vasović committed
338
// Animations
Bas Bosman's avatar
Bas Bosman committed
339
340
//
// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Zlatan Vasović's avatar
Zlatan Vasović committed
341
342
.animation(@animation) {
  -webkit-animation: @animation;
Bas Bosman's avatar
Bas Bosman committed
343
       -o-animation: @animation;
Zlatan Vasović's avatar
Zlatan Vasović committed
344
345
          animation: @animation;
}
Bas Bosman's avatar
Bas Bosman committed
346
347

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Zlatan Vasović's avatar
Zlatan Vasović committed
348
349
350
351
.animation-name(@name) {
  -webkit-animation-name: @name;
          animation-name: @name;
}
Bas Bosman's avatar
Bas Bosman committed
352
353

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Zlatan Vasović's avatar
Zlatan Vasović committed
354
355
356
357
.animation-duration(@duration) {
  -webkit-animation-duration: @duration;
          animation-duration: @duration;
}
Bas Bosman's avatar
Bas Bosman committed
358
359

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Zlatan Vasović's avatar
Zlatan Vasović committed
360
361
362
363
.animation-timing-function(@timing-function) {
  -webkit-animation-timing-function: @timing-function;
          animation-timing-function: @timing-function;
}
Bas Bosman's avatar
Bas Bosman committed
364
365

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Zlatan Vasović's avatar
Zlatan Vasović committed
366
367
368
369
.animation-delay(@delay) {
  -webkit-animation-delay: @delay;
          animation-delay: @delay;
}
Bas Bosman's avatar
Bas Bosman committed
370
371

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Zlatan Vasović's avatar
Zlatan Vasović committed
372
373
374
375
.animation-iteration-count(@iteration-count) {
  -webkit-animation-iteration-count: @iteration-count;
          animation-iteration-count: @iteration-count;
}
Bas Bosman's avatar
Bas Bosman committed
376
377

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
Zlatan Vasović's avatar
Zlatan Vasović committed
378
379
380
381
.animation-direction(@direction) {
  -webkit-animation-direction: @direction;
          animation-direction: @direction;
}
382
383
384
385
.animation-fill-mode(@fill-mode) {
  -webkit-animation-fill-mode: @fill-mode;
          animation-fill-mode: @fill-mode;
}
386

387
388
// Backface visibility
// Prevent browsers from flickering when using CSS 3D transforms.
Chris Rebert's avatar
Chris Rebert committed
389
// Default value is `visible`, but can be changed to `hidden`
Bas Bosman's avatar
Bas Bosman committed
390
// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
391
.backface-visibility(@visibility){
392
393
394
  -webkit-backface-visibility: @visibility;
     -moz-backface-visibility: @visibility;
          backface-visibility: @visibility;
395
396
}

397
// Box sizing
Bas Bosman's avatar
Bas Bosman committed
398
// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
399
400
401
402
403
404
.box-sizing(@boxmodel) {
  -webkit-box-sizing: @boxmodel;
     -moz-box-sizing: @boxmodel;
          box-sizing: @boxmodel;
}

405
406
// User select
// For selecting text on the page
Bas Bosman's avatar
Bas Bosman committed
407
// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
408
409
410
.user-select(@select) {
  -webkit-user-select: @select;
     -moz-user-select: @select;
411
      -ms-user-select: @select; // IE10+
412
413
414
          user-select: @select;
}

415
// Resize anything
416
.resizable(@direction) {
417
418
419
420
  resize: @direction; // Options: horizontal, vertical, both
  overflow: auto; // Safari fix
}

421
// CSS3 Content Columns
422
.content-columns(@column-count; @column-gap: @grid-gutter-width) {
423
424
425
426
427
428
  -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;
429
430
}

Synchro's avatar
Synchro committed
431
432
// Optional hyphenation
.hyphens(@mode: auto) {
Mark Otto's avatar
Mark Otto committed
433
  word-wrap: break-word;
Synchro's avatar
Synchro committed
434
435
  -webkit-hyphens: @mode;
     -moz-hyphens: @mode;
436
      -ms-hyphens: @mode; // IE10+
Synchro's avatar
Synchro committed
437
       -o-hyphens: @mode;
Synchro's avatar
Synchro committed
438
439
440
          hyphens: @mode;
}

441
// Opacity
442
.opacity(@opacity) {
443
444
  opacity: @opacity;
  // IE8 filter
445
  @opacity-ie: (@opacity * 100);
446
  filter: ~"alpha(opacity=@{opacity-ie})";
447
448
449
450
}



Mark Otto's avatar
Mark Otto committed
451
// Gradients
452
453
// --------------------------------------------------

454
#gradient {
Mark Otto's avatar
Mark Otto committed
455
456
457
458
459

  // 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.
460
  .horizontal(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
461
    background-image: -webkit-linear-gradient(left, color-stop(@start-color @start-percent), color-stop(@end-color @end-percent)); // Safari 5.1-6, Chrome 10+
Bas Bosman's avatar
Bas Bosman committed
462
463
    background-image: -o-linear-gradient(left, @start-color @start-percent, @end-color @end-percent); // Opera 12
    background-image: linear-gradient(to right, @start-color @start-percent, @end-color @end-percent); // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+
464
    background-repeat: repeat-x;
Mark Otto's avatar
Mark Otto committed
465
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@start-color),argb(@end-color))); // IE9 and down
466
  }
Mark Otto's avatar
Mark Otto committed
467
468
469
470
471

  // 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.
472
  .vertical(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
473
    background-image: -webkit-linear-gradient(top, @start-color @start-percent, @end-color @end-percent);  // Safari 5.1-6, Chrome 10+
Bas Bosman's avatar
Bas Bosman committed
474
    background-image: -o-linear-gradient(top, @start-color @start-percent, @end-color @end-percent);  // Opera 12
475
    background-image: linear-gradient(to bottom, @start-color @start-percent, @end-color @end-percent); // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+
476
    background-repeat: repeat-x;
Mark Otto's avatar
Mark Otto committed
477
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@start-color),argb(@end-color))); // IE9 and down
478
  }
Mark Otto's avatar
Mark Otto committed
479

480
  .directional(@start-color: #555; @end-color: #333; @deg: 45deg) {
481
    background-repeat: repeat-x;
482
    background-image: -webkit-linear-gradient(@deg, @start-color, @end-color); // Safari 5.1-6, Chrome 10+
Bas Bosman's avatar
Bas Bosman committed
483
    background-image: -o-linear-gradient(@deg, @start-color, @end-color); // Opera 12
484
    background-image: linear-gradient(@deg, @start-color, @end-color); // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+
485
  }
486
  .horizontal-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
Mark Otto's avatar
Mark Otto committed
487
    background-image: -webkit-linear-gradient(left, @start-color, @mid-color @color-stop, @end-color);
Bas Bosman's avatar
Bas Bosman committed
488
    background-image: -o-linear-gradient(left, @start-color, @mid-color @color-stop, @end-color);
Mark Otto's avatar
Mark Otto committed
489
    background-image: linear-gradient(to right, @start-color, @mid-color @color-stop, @end-color);
Francisco arenas's avatar
Francisco arenas committed
490
    background-repeat: no-repeat;
Mark Otto's avatar
Mark Otto committed
491
    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
492
  }
493
  .vertical-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
Mark Otto's avatar
Mark Otto committed
494
    background-image: -webkit-linear-gradient(@start-color, @mid-color @color-stop, @end-color);
Bas Bosman's avatar
Bas Bosman committed
495
    background-image: -o-linear-gradient(@start-color, @mid-color @color-stop, @end-color);
Mark Otto's avatar
Mark Otto committed
496
    background-image: linear-gradient(@start-color, @mid-color @color-stop, @end-color);
497
    background-repeat: no-repeat;
Mark Otto's avatar
Mark Otto committed
498
    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
499
  }
500
  .radial(@inner-color: #555; @outer-color: #333) {
Mark Otto's avatar
Mark Otto committed
501
502
    background-image: -webkit-radial-gradient(circle, @inner-color, @outer-color);
    background-image: radial-gradient(circle, @inner-color, @outer-color);
503
504
    background-repeat: no-repeat;
  }
505
506
  .striped(@color: rgba(255,255,255,.15); @angle: 45deg) {
    background-image: -webkit-linear-gradient(@angle, @color 25%, transparent 25%, transparent 50%, @color 50%, @color 75%, transparent 75%, transparent);
Bas Bosman's avatar
Bas Bosman committed
507
    background-image: -o-linear-gradient(@angle, @color 25%, transparent 25%, transparent 50%, @color 50%, @color 75%, transparent 75%, transparent);
508
    background-image: linear-gradient(@angle, @color 25%, transparent 25%, transparent 50%, @color 50%, @color 75%, transparent 75%, transparent);
Piotrek Okoński's avatar
Piotrek Okoński committed
509
  }
510
}
Mark Otto's avatar
Mark Otto committed
511

512
// Reset filters for IE
Mark Otto's avatar
Mark Otto committed
513
//
Mike Pagé's avatar
Mike Pagé committed
514
// When you need to remove a gradient background, do not forget to use this to reset
Mark Otto's avatar
Mark Otto committed
515
// the IE filter for IE9 and below.
516
.reset-filter() {
517
  filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
518
}
519

520

Mark Otto's avatar
Mark Otto committed
521

522
// Retina images
Mark Otto's avatar
Mark Otto committed
523
524
// --------------------------------------------------

Mark Otto's avatar
Mark Otto committed
525
526
// Short retina mixin for setting background-image and -size. Note that the
// spelling of `min--moz-device-pixel-ratio` is intentional.
527
.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
Mark Otto's avatar
Mark Otto committed
528
529
530
531
  background-image: url("@{file-1x}");

  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
Mark Otto's avatar
Mark Otto committed
532
  only screen and (   min--moz-device-pixel-ratio: 2),
Mark Otto's avatar
Mark Otto committed
533
534
535
536
537
538
539
  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
540
541
}

542

Mark Otto's avatar
Mark Otto committed
543

544
// Responsive image
Mark Otto's avatar
Mark Otto committed
545
// --------------------------------------------------
546

Mark Otto's avatar
Mark Otto committed
547
// Keep images from scaling beyond the width of their parents.
Zlatan Vasović's avatar
Zlatan Vasović committed
548
.img-responsive(@display: block) {
549
550
551
552
553
554
  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
}


Mark Otto's avatar
Mark Otto committed
555
556

// Component mixins
557
558
// --------------------------------------------------

559
// Horizontal dividers
Mark Otto's avatar
Mark Otto committed
560
//
561
// Dividers (basically an hr) within dropdowns and nav lists
Mark Otto's avatar
Mark Otto committed
562
563
.nav-divider(@color: #e5e5e5) {
  height: 1px;
564
  margin: ((@line-height-computed / 2) - 1) 0;
Jacob Thornton's avatar
Jacob Thornton committed
565
  overflow: hidden;
Mark Otto's avatar
Mark Otto committed
566
  background-color: @color;
567
568
}

569
// Panels
570
.panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) {
571
  border-color: @border;
Mark Otto's avatar
spacing    
Mark Otto committed
572

573
  & > .panel-heading {
574
575
576
    color: @heading-text-color;
    background-color: @heading-bg-color;
    border-color: @heading-border;
Mark Otto's avatar
spacing    
Mark Otto committed
577

578
    + .panel-collapse > .panel-body {
Mark Otto's avatar
Mark Otto committed
579
580
581
      border-top-color: @border;
    }
  }
582
  & > .panel-footer {
583
    + .panel-collapse > .panel-body {
Mark Otto's avatar
Mark Otto committed
584
585
      border-bottom-color: @border;
    }
586
587
588
  }
}

Chris Rebert's avatar
Chris Rebert committed
589
// Alerts
590
.alert-variant(@background; @border; @text-color) {
Chris Rebert's avatar
Chris Rebert committed
591
592
593
  background-color: @background;
  border-color: @border;
  color: @text-color;
Mark Otto's avatar
spacing    
Mark Otto committed
594

Chris Rebert's avatar
Chris Rebert committed
595
596
597
598
599
600
601
602
  hr {
    border-top-color: darken(@border, 5%);
  }
  .alert-link {
    color: darken(@text-color, 10%);
  }
}

ggam's avatar
ggam committed
603
// Tables
Zlatan Vasović's avatar
Zlatan Vasović committed
604
.table-row-variant(@state; @background) {
ggam's avatar
ggam committed
605
606
  // Exact selectors below required to override `.table-striped` and prevent
  // inheritance to nested tables.
607
608
609
610
611
612
613
614
  .table > thead > tr,
  .table > tbody > tr,
  .table > tfoot > tr {
    > td.@{state},
    > th.@{state},
    &.@{state} > td,
    &.@{state} > th {
      background-color: @background;
ggam's avatar
ggam committed
615
616
    }
  }
617

ggam's avatar
ggam committed
618
619
  // Hover states for `.table-hover`
  // Note: this is not available for cells or rows within `thead` or `tfoot`.
620
621
622
623
624
  .table-hover > tbody > tr {
    > td.@{state}:hover,
    > th.@{state}:hover,
    &.@{state}:hover > td,
    &.@{state}:hover > th {
ggam's avatar
ggam committed
625
626
627
628
629
      background-color: darken(@background, 5%);
    }
  }
}

630
// List Groups
Mark Otto's avatar
Mark Otto committed
631
632
633
.list-group-item-variant(@state; @background; @color) {
  .list-group-item-@{state} {
    color: @color;
634
    background-color: @background;
Mark Otto's avatar
Mark Otto committed
635

636
    a& {
Mark Otto's avatar
Mark Otto committed
637
      color: @color;
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652

      .list-group-item-heading { color: inherit; }

      &:hover,
      &:focus {
        color: @color;
        background-color: darken(@background, 5%);
      }
      &.active,
      &.active:hover,
      &.active:focus {
        color: #fff;
        background-color: @color;
        border-color: @color;
      }
Mark Otto's avatar
Mark Otto committed
653
    }
654
655
656
  }
}

657
// Button variants
Mark Otto's avatar
Mark Otto committed
658
//
659
660
// Easily pump out default styles, as well as :hover, :focus, :active,
// and disabled options for all buttons
661
.button-variant(@color; @background; @border) {
662
  color: @color;
663
664
  background-color: @background;
  border-color: @border;
665

Mark Otto's avatar
Mark Otto committed
666
  &:hover,
667
  &:focus,
668
  &:active,
669
670
  &.active,
  .open .dropdown-toggle& {
671
    color: @color;
672
    background-color: darken(@background, 10%);
673
        border-color: darken(@border, 12%);
Mark Otto's avatar
Mark Otto committed
674
  }
675
676
677
678
679
  &:active,
  &.active,
  .open .dropdown-toggle& {
    background-image: none;
  }
680
  &.disabled,
681
  &[disabled],
682
  fieldset[disabled] & {
683
    &,
684
685
    &:hover,
    &:focus,
686
687
    &:active,
    &.active {
688
      background-color: @background;
Zlatan Vasović's avatar
Zlatan Vasović committed
689
          border-color: @border;
690
    }
691
  }
692
693
694

  .badge {
    color: @background;
695
    background-color: @color;
696
  }
697
698
}

ggam's avatar
ggam committed
699
700
701
702
703
704
705
706
// 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
707
// Pagination
Guillermo González de Agüero's avatar
Guillermo González de Agüero committed
708
.pagination-size(@padding-vertical; @padding-horizontal; @font-size; @border-radius) {
ggam's avatar
ggam committed
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
  > 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
730
731
732
733
734
735
736
737
738
739
740
// Labels
.label-variant(@color) {
  background-color: @color;
  &[href] {
    &:hover,
    &:focus {
      background-color: darken(@color, 10%);
    }
  }
}

741
742
743
744
745
746
747
748
// Contextual backgrounds
.bg-variant(@color) {
  background-color: @color;
  a&:hover {
    background-color: darken(@color, 10%);
  }
}

749
750
751
// Typography
.text-emphasis-variant(@color) {
  color: @color;
752
  a&:hover {
753
754
755
756
    color: darken(@color, 10%);
  }
}

757
// Navbar vertical align
Mark Otto's avatar
Mark Otto committed
758
//
759
// Vertically center elements in the navbar.
760
// 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
761
.navbar-vertical-align(@element-height) {
762
763
  margin-top: ((@navbar-height - @element-height) / 2);
  margin-bottom: ((@navbar-height - @element-height) / 2);
764
765
}

766
767
768
769
// Progress bars
.progress-bar-variant(@color) {
  background-color: @color;
  .progress-striped & {
770
    #gradient > .striped();
771
772
773
  }
}

Mark Otto's avatar
Mark Otto committed
774
// Responsive utilities
Mark Otto's avatar
Mark Otto committed
775
//
Mark Otto's avatar
Mark Otto committed
776
777
778
// More easily include all the states for responsive-utilities.less.
.responsive-visibility() {
  display: block !important;
779
780
  table&  { display: table; }
  tr&     { display: table-row !important; }
Mark Otto's avatar
Mark Otto committed
781
  th&,
782
  td&     { display: table-cell !important; }
Mark Otto's avatar
Mark Otto committed
783
784
}

785
.responsive-invisibility() {
Zlatan Vasović's avatar
Zlatan Vasović committed
786
  display: none !important;
787
788
}

789

Mark Otto's avatar
Mark Otto committed
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880

// Form validation states
//
// Used in forms.less to generate the form validation CSS for warnings, errors,
// and successes.

.form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) {
  // Color the label and help text
  .help-block,
  .control-label,
  .radio,
  .checkbox,
  .radio-inline,
  .checkbox-inline  {
    color: @text-color;
  }
  // Set the border and box shadow on specific inputs to match
  .form-control {
    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);
    }
  }
  // Set validation states also for addons
  .input-group-addon {
    color: @text-color;
    border-color: @border-color;
    background-color: @background-color;
  }
  // Optional feedback icon
  .form-control-feedback {
    color: @text-color;
  }
}



// Forms
// --------------------------------------------------

// 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}");
  }
}

// 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;

  select& {
    height: @input-height;
    line-height: @input-height;
  }

  textarea&,
  select[multiple]& {
    height: auto;
  }
}



// Grid system
// --------------------------------------------------
881

882
// Centered container element
883
884
.container-fixed() {
  margin-right: auto;
Jacob Thornton's avatar
Jacob Thornton committed
885
  margin-left: auto;
886
887
  padding-left:  (@grid-gutter-width / 2);
  padding-right: (@grid-gutter-width / 2);
888
  &:extend(.clearfix all);
889
890
}

891
// Creates a wrapper for a series of columns
892
.make-row(@gutter: @grid-gutter-width) {
893
894
  margin-left:  (@gutter / -2);
  margin-right: (@gutter / -2);
895
  &:extend(.clearfix all);
896
}
Mark Otto's avatar
Mark Otto committed
897

898
899
// Generate the extra small columns
.make-xs-column(@columns; @gutter: @grid-gutter-width) {
900
901
  position: relative;
  float: left;
902
  width: percentage((@columns / @grid-columns));
903
904
905
906
  min-height: 1px;
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
}
907
.make-xs-column-offset(@columns) {
908
  margin-left: percentage((@columns / @grid-columns));
909
910
}
.make-xs-column-push(@columns) {
911
  left: percentage((@columns / @grid-columns));
912
913
}
.make-xs-column-pull(@columns) {
914
  right: percentage((@columns / @grid-columns));
915
}
916
917

// Generate the small columns
918
.make-sm-column(@columns; @gutter: @grid-gutter-width) {
919
  position: relative;
920
  min-height: 1px;
921
922
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
923

924
  @media (min-width: @screen-sm-min) {
925
    float: left;
926
927
    width: percentage((@columns / @grid-columns));
  }
928
}
929
.make-sm-column-offset(@columns) {
930
  @media (min-width: @screen-sm-min) {
931
932
933
    margin-left: percentage((@columns / @grid-columns));
  }
}
934
.make-sm-column-push(@columns) {
935
  @media (min-width: @screen-sm-min) {
936
937
938
    left: percentage((@columns / @grid-columns));
  }
}
939
.make-sm-column-pull(@columns) {
940
  @media (min-width: @screen-sm-min) {
941
942
    right: percentage((@columns / @grid-columns));
  }
943
}
944

945
946
// Generate the medium columns
.make-md-column(@columns; @gutter: @grid-gutter-width) {
Bass Jobsen's avatar
Bass Jobsen committed
947
948
  position: relative;
  min-height: 1px;
949
950
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
Mark Otto's avatar
Mark Otto committed
951

952
  @media (min-width: @screen-md-min) {
953
    float: left;
Bass Jobsen's avatar
Bass Jobsen committed
954
955
956
    width: percentage((@columns / @grid-columns));
  }
}
957
.make-md-column-offset(@columns) {
958
  @media (min-width: @screen-md-min) {
959
960
961
    margin-left: percentage((@columns / @grid-columns));
  }
}
962
.make-md-column-push(@columns) {
963
  @media (min-width: @screen-md-min) {
964
965
966
    left: percentage((@columns / @grid-columns));
  }
}
967
.make-md-column-pull(@columns) {
968
  @media (min-width: @screen-md-min) {
969
970
971
972
    right: percentage((@columns / @grid-columns));
  }
}

973
974
975
976
977
978
979
// Generate the large columns
.make-lg-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  min-height: 1px;
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);

980
  @media (min-width: @screen-lg-min) {
981
982
983
984
985
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-offset(@columns) {
986
  @media (min-width: @screen-lg-min) {
987
988
989
990
    margin-left: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-push(@columns) {
991
  @media (min-width: @screen-lg-min) {
992
993
994
995
    left: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-pull(@columns) {
996
  @media (min-width: @screen-lg-min) {
997
998
999
1000
    right: percentage((@columns / @grid-columns));
  }
}

For faster browsing, not all history is shown. View entire blame