mixins.less 32.1 KB
Newer Older
1
2
3
//
// Mixins
// --------------------------------------------------
4
//
5
// TABLE OF CONTENTS
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// UTILITIES
// -------------------------
// - 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
//
// CSS3 PROPERTIES
// --------------------------------------------------
// - 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
//
// GRADIENTS
// --------------------------------------------------
// - Reset filters for IE
// - Retina images
// - Responsive image
//
// COMPONENT MIXINS
// --------------------------------------------------
// - 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
56
// - Vertically center elements in the navbar
57
58
59
60
61
62
63
64
65
66
67
68
// - Progress bars
//
// RESPONSIVE UTILITIES
// -------------------------
// Grid System
// -----------
// - Centered container element
// - Generate the extra small columns
// - Generate the small columns
// - Generate the medium columns
// - Generate the large columns
// - Framework grid generation
69
// - Loop to generate grid all grid classes
70
71
// - Form validation states
// - Form control focus state
72

73

74
75
// Utilities
// -------------------------
76
77

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

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

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

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

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

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

139
// CSS image replacement
140
141
142
//
// 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
143
// of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`.
144
//
145
// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
146

147
148
149
150
151
152
153
154
155
// 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
156
.text-hide() {
157
  .hide-text();
158
}
159

160

161

162
163
164
// CSS3 PROPERTIES
// --------------------------------------------------

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

183
// Drop shadows
184
185
186
187
//
// 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
188
.box-shadow(@shadow) {
189
  -webkit-box-shadow: @shadow; // iOS <4.3 & Android <4.1
190
          box-shadow: @shadow;
191
192
193
}

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

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

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

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

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

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

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

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

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

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

// Deprecated as of v3.2.0 due to the introduction of autoprefixer (will be removed in v4)
269
270
271
.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
272
       -o-transform: skew(@x, @y);
273
          transform: skew(@x, @y);
274
}
Bas Bosman's avatar
Bas Bosman committed
275
276

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



Mark Otto's avatar
Mark Otto committed
449
// GRADIENTS
450
451
// --------------------------------------------------

452
#gradient {
Mark Otto's avatar
Mark Otto committed
453
454
455
456
457

  // 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.
458
  .horizontal(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
459
    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
460
461
    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+
462
    background-repeat: repeat-x;
Mark Otto's avatar
Mark Otto committed
463
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@start-color),argb(@end-color))); // IE9 and down
464
  }
Mark Otto's avatar
Mark Otto committed
465
466
467
468
469

  // 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.
470
  .vertical(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
471
    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
472
    background-image: -o-linear-gradient(top, @start-color @start-percent, @end-color @end-percent);  // Opera 12
473
    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+
474
    background-repeat: repeat-x;
Mark Otto's avatar
Mark Otto committed
475
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@start-color),argb(@end-color))); // IE9 and down
476
  }
Mark Otto's avatar
Mark Otto committed
477

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

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

518

Mark Otto's avatar
Mark Otto committed
519

520
521
// Retina images
//
Mark Otto's avatar
Mark Otto committed
522
523
// Short retina mixin for setting background-image and -size. Note that the
// spelling of `min--moz-device-pixel-ratio` is intentional.
524

525
.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
Mark Otto's avatar
Mark Otto committed
526
527
528
529
  background-image: url("@{file-1x}");

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

540

541
542
543
544
// Responsive image
//
// Keep images from scaling beyond the width of their parents.

Zlatan Vasović's avatar
Zlatan Vasović committed
545
.img-responsive(@display: block) {
546
547
548
549
550
551
  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
}


552
553
554
// COMPONENT MIXINS
// --------------------------------------------------

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

565
566
// Panels
// -------------------------
567
.panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) {
568
  border-color: @border;
Mark Otto's avatar
spacing    
Mark Otto committed
569

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

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

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

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

ggam's avatar
ggam committed
601
602
// Tables
// -------------------------
Zlatan Vasović's avatar
Zlatan Vasović committed
603
.table-row-variant(@state; @background) {
ggam's avatar
ggam committed
604
605
  // Exact selectors below required to override `.table-striped` and prevent
  // inheritance to nested tables.
606
607
608
609
610
611
612
613
  .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
614
615
    }
  }
616

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

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

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

753
754
755
756
// Typography
// -------------------------
.text-emphasis-variant(@color) {
  color: @color;
757
  a&:hover {
758
759
760
761
    color: darken(@color, 10%);
  }
}

762
763
764
// Navbar vertical align
// -------------------------
// Vertically center elements in the navbar.
765
// 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
766
.navbar-vertical-align(@element-height) {
767
768
  margin-top: ((@navbar-height - @element-height) / 2);
  margin-bottom: ((@navbar-height - @element-height) / 2);
769
770
}

771
772
773
774
775
// Progress bars
// -------------------------
.progress-bar-variant(@color) {
  background-color: @color;
  .progress-striped & {
776
    #gradient > .striped();
777
778
779
  }
}

Mark Otto's avatar
Mark Otto committed
780
781
782
783
784
// Responsive utilities
// -------------------------
// More easily include all the states for responsive-utilities.less.
.responsive-visibility() {
  display: block !important;
785
786
  table&  { display: table; }
  tr&     { display: table-row !important; }
Mark Otto's avatar
Mark Otto committed
787
  th&,
788
  td&     { display: table-cell !important; }
Mark Otto's avatar
Mark Otto committed
789
790
}

791
.responsive-invisibility() {
Zlatan Vasović's avatar
Zlatan Vasović committed
792
  display: none !important;
793
794
}

795

796
797
798
// Grid System
// -----------

799
// Centered container element
800
801
.container-fixed() {
  margin-right: auto;
Jacob Thornton's avatar
Jacob Thornton committed
802
  margin-left: auto;
803
804
  padding-left:  (@grid-gutter-width / 2);
  padding-right: (@grid-gutter-width / 2);
805
  &:extend(.clearfix all);
806
807
}

808
// Creates a wrapper for a series of columns
809
.make-row(@gutter: @grid-gutter-width) {
810
811
  margin-left:  (@gutter / -2);
  margin-right: (@gutter / -2);
812
  &:extend(.clearfix all);
813
}
Mark Otto's avatar
Mark Otto committed
814

815
816
// Generate the extra small columns
.make-xs-column(@columns; @gutter: @grid-gutter-width) {
817
818
  position: relative;
  float: left;
819
  width: percentage((@columns / @grid-columns));
820
821
822
823
  min-height: 1px;
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
}
824
.make-xs-column-offset(@columns) {
825
  margin-left: percentage((@columns / @grid-columns));
826
827
}
.make-xs-column-push(@columns) {
828
  left: percentage((@columns / @grid-columns));
829
830
}
.make-xs-column-pull(@columns) {
831
  right: percentage((@columns / @grid-columns));
832
}
833

Mark Otto's avatar
Mark Otto committed
834

835
// Generate the small columns
836
.make-sm-column(@columns; @gutter: @grid-gutter-width) {
837
  position: relative;
838
  min-height: 1px;
839
840
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
841

842
  @media (min-width: @screen-sm-min) {
843
    float: left;
844
845
    width: percentage((@columns / @grid-columns));
  }
846
}
847
.make-sm-column-offset(@columns) {
848
  @media (min-width: @screen-sm-min) {
849
850
851
    margin-left: percentage((@columns / @grid-columns));
  }
}
852
.make-sm-column-push(@columns) {
853
  @media (min-width: @screen-sm-min) {
854
855
856
    left: percentage((@columns / @grid-columns));
  }
}
857
.make-sm-column-pull(@columns) {
858
  @media (min-width: @screen-sm-min) {
859
860
    right: percentage((@columns / @grid-columns));
  }
861
}
862

Mark Otto's avatar
Mark Otto committed
863

864
865
// Generate the medium columns
.make-md-column(@columns; @gutter: @grid-gutter-width) {
Bass Jobsen's avatar
Bass Jobsen committed
866
867
  position: relative;
  min-height: 1px;
868
869
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);
Mark Otto's avatar
Mark Otto committed
870

871
  @media (min-width: @screen-md-min) {
872
    float: left;
Bass Jobsen's avatar
Bass Jobsen committed
873
874
875
    width: percentage((@columns / @grid-columns));
  }
}
876
.make-md-column-offset(@columns) {
877
  @media (min-width: @screen-md-min) {
878
879
880
    margin-left: percentage((@columns / @grid-columns));
  }
}
881
.make-md-column-push(@columns) {
882
  @media (min-width: @screen-md-min) {
883
884
885
    left: percentage((@columns / @grid-columns));
  }
}
886
.make-md-column-pull(@columns) {
887
  @media (min-width: @screen-md-min) {
888
889
890
891
    right: percentage((@columns / @grid-columns));
  }
}

Mark Otto's avatar
Mark Otto committed
892

893
894
895
896
897
898
899
// 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);

900
  @media (min-width: @screen-lg-min) {
901
902
903
904
905
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-offset(@columns) {
906
  @media (min-width: @screen-lg-min) {
907
908
909
910
    margin-left: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-push(@columns) {
911
  @media (min-width: @screen-lg-min) {
912
913
914
915
    left: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-pull(@columns) {
916
  @media (min-width: @screen-lg-min) {
917
918
919
920
    right: percentage((@columns / @grid-columns));
  }
}

Mark Otto's avatar
Mark Otto committed
921

922
923
924
925
926
927
928
929
930
// Framework grid generation
//
// Used only by Bootstrap to generate the correct number of grid classes given
// any value of `@grid-columns`.

.make-grid-columns() {
  // Common styles for all sizes of grid columns, widths 1-12
  .col(@index) when (@index = 1) { // initial
    @item: ~".col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}";
931
    .col((@index + 1), @item);
932
933
934
  }
  .col(@index, @list) when (@index =< @grid-columns) { // general; "=<" isn't a typo
    @item: ~".col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}";
935
    .col((@index + 1), ~"@{list}, @{item}");
936
937
938
939
940
941
942
943
944
945
946
947
948
949
  }
  .col(@index, @list) when (@index > @grid-columns) { // terminal
    @{list} {
      position: relative;
      // Prevent columns from collapsing when empty
      min-height: 1px;
      // Inner gutter via padding
      padding-left:  (@grid-gutter-width / 2);
      padding-right: (@grid-gutter-width / 2);
    }
  }
  .col(1); // kickstart it
}

950
.float-grid-columns(@class) {
951
952
  .col(@index) when (@index = 1) { // initial
    @item: ~".col-@{class}-@{index}";
953
    .col((@index + 1), @item);
954
  }
955
  .col(@index, @list) when (@index =< @grid-columns) { // general
956
    @item: ~".col-@{class}-@{index}";
957
    .col((@index + 1), ~"@{list}, @{item}");
958
  }
959
  .col(@index, @list) when (@index > @grid-columns) { // terminal
960
961
962
963
964
965
966
    @{list} {
      float: left;
    }
  }
  .col(1); // kickstart it
}

967
.calc-grid-column(@index, @class, @type) when (@type = width) and (@index > 0) {
968
969
970
971
  .col-@{class}-@{index} {
    width: percentage((@index / @grid-columns));
  }
}
972
.calc-grid-column(@index, @class, @type) when (@type = push) and (@index > 0) {
973
974
975
976
  .col-@{class}-push-@{index} {
    left: percentage((@index / @grid-columns));
  }
}
977
978
979
980
981
982
.calc-grid-column(@index, @class, @type) when (@type = push) and (@index = 0) {
  .col-@{class}-push-0 {
    left: auto;
  }
}
.calc-grid-column(@index, @class, @type) when (@type = pull) and (@index > 0) {
983
984
985
986
  .col-@{class}-pull-@{index} {
    right: percentage((@index / @grid-columns));
  }
}
987
988
989
990
991
.calc-grid-column(@index, @class, @type) when (@type = pull) and (@index = 0) {
  .col-@{class}-pull-0 {
    right: auto;
  }
}
992
.calc-grid-column(@index, @class, @type) when (@type = offset) {
993
994
995
996
997
998
  .col-@{class}-offset-@{index} {
    margin-left: percentage((@index / @grid-columns));
  }
}

// Basic looping in LESS
999
1000
.loop-grid-columns(@index, @class, @type) when (@index >= 0) {
  .calc-grid-column(@index, @class, @type);
For faster browsing, not all history is shown. View entire blame