5
<title>Less · Twitter Bootstrap</title>
6
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7
<meta name="description" content="">
8
<meta name="author" content="">
11
<link href="assets/css/bootstrap.css" rel="stylesheet">
12
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
13
<link href="assets/css/docs.css" rel="stylesheet">
14
<link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">
16
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
18
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
21
<!-- Le fav and touch icons -->
22
<link rel="shortcut icon" href="assets/ico/favicon.ico">
23
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
24
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
25
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
28
<body data-spy="scroll" data-target=".subnav" data-offset="50">
32
================================================== -->
33
<div class="navbar navbar-fixed-top">
34
<div class="navbar-inner">
35
<div class="container">
36
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
37
<span class="icon-bar"></span>
38
<span class="icon-bar"></span>
39
<span class="icon-bar"></span>
41
<a class="brand" href="./index.html">Bootstrap</a>
42
<div class="nav-collapse">
45
<a href="./index.html">Overview</a>
48
<a href="./scaffolding.html">Scaffolding</a>
51
<a href="./base-css.html">Base CSS</a>
54
<a href="./components.html">Components</a>
57
<a href="./javascript.html">Javascript plugins</a>
60
<a href="./less.html">Using LESS</a>
62
<li class="divider-vertical"></li>
64
<a href="./download.html">Customize</a>
67
<a href="./examples.html">Examples</a>
75
<div class="container">
78
================================================== -->
79
<header class="jumbotron subhead" id="overview">
80
<h1>Using LESS with Bootstrap</h1>
81
<p class="lead">Customize and extend Bootstrap with <a href="http://lesscss.org" target="_blank">LESS</a>, a CSS preprocessor, to take advantage of the variables, mixins, and more used to build Bootstrap's CSS.</p>
83
<ul class="nav nav-pills">
84
<li><a href="#builtWith">Built with Less</a></li>
85
<li><a href="#variables">Variables</a></li>
86
<li><a href="#mixins">Mixins</a></li>
87
<li><a href="#compiling">Compiling Bootstrap</a></li>
95
================================================== -->
96
<section id="builtWith">
97
<div class="page-header">
98
<h1>Built with LESS</h1>
103
<p>Bootstrap is made with LESS at its core, a dynamic stylesheet language created by our good friend, <a href="http://cloudhead.io">Alexis Sellier</a>. It makes developing systems-based CSS faster, easier, and more fun.</p>
106
<h3>What's included?</h3>
107
<p>As an extension of CSS, LESS includes variables, mixins for reusable snippets of code, operations for simple math, nesting, and even color functions.</p>
111
<img style="float: right; height: 36px;" src="assets/img/less-logo-large.png" alt="LESS CSS">
112
<p>Visit the official website at <a href="http://lesscss.org">http://lesscss.org</a> to learn more.</p>
117
<h3><a href="#variables">Variables</a></h3>
118
<p>Managing colors and pixel values in CSS can be a bit of a pain, usually full of copy and paste. Not with LESS though—assign colors or pixel values as variables and change them once.</p>
121
<h3><a href="#mixins">Mixins</a></h3>
122
<p>Those three border-radius declarations you need to make in regular ol' CSS? Now they're down to one line with the help of mixins, snippets of code you can reuse anywhere.</p>
126
<p>Make your grid, leading, and more super flexible by doing the math on the fly with operations. Multiply, divide, add, and subtract your way to CSS sanity.</p>
134
================================================== -->
135
<section id="variables">
136
<div class="page-header">
137
<h1>Bootstrap variables <small>LESS variables, their values, and usage guidelines</small></h1>
143
<table class="table table-bordered table-striped">
146
<td class="span2"><code>@linkColor</code></td>
148
<td>Default link text color</td>
149
<td class="swatch-col"><span class="swatch" style="background-color: #08c;"></span></td>
152
<td><code>@linkColorHover</code></td>
153
<td><code>darken(@linkColor, 15%)</code></td>
154
<td>Default link text hover color</td>
155
<td><span class="swatch" style="background-color: #005580;"></span></td>
160
<table class="table table-bordered table-striped">
163
<td class="span2"><code>@gridColumns</code></td>
167
<td><code>@gridColumnWidth</code></td>
171
<td><code>@gridGutterWidth</code></td>
175
<td><code>@fluidGridColumnWidth</code></td>
176
<td>6.382978723%</td>
179
<td><code>@fluidGridGutterWidth</code></td>
180
<td>2.127659574%</td>
185
<table class="table table-bordered table-striped">
188
<td class="span2"><code>@baseFontSize</code></td>
192
<td><code>@baseFontFamily</code></td>
193
<td><code>"Helvetica Neue", Helvetica, Arial, sans-serif</code></td>
196
<td><code>@baseLineHeight</code></td>
203
<h3>Grayscale colors</h3>
204
<table class="table table-bordered table-striped">
207
<td class="span2"><code>@black</code></td>
209
<td class="swatch-col"><span class="swatch" style="background-color: #000;"></span></td>
212
<td><code>@grayDarker</code></td>
214
<td><span class="swatch" style="background-color: #222;"></span></td>
217
<td><code>@grayDark</code></td>
219
<td><span class="swatch" style="background-color: #333;"></span></td>
222
<td><code>@gray</code></td>
224
<td><span class="swatch" style="background-color: #555;"></span></td>
227
<td><code>@grayLight</code></td>
229
<td><span class="swatch" style="background-color: #999;"></span></td>
232
<td><code>@grayLighter</code></td>
234
<td><span class="swatch" style="background-color: #eee;"></span></td>
237
<td><code>@white</code></td>
239
<td><span class="swatch swatch-bordered" style="background-color: #fff;"></span></td>
243
<h3>Accent colors</h3>
244
<table class="table table-bordered table-striped">
247
<td class="span2"><code>@blue</code></td>
249
<td class="swatch-col"><span class="swatch" style="background-color: #049cdb;"></span></td>
252
<td><code>@green</code></td>
254
<td><span class="swatch" style="background-color: #46a546;"></span></td>
257
<td><code>@red</code></td>
259
<td><span class="swatch" style="background-color: #9d261d;"></span></td>
262
<td><code>@yellow</code></td>
264
<td><span class="swatch" style="background-color: #ffc40d;"></span></td>
267
<td><code>@orange</code></td>
269
<td><span class="swatch" style="background-color: #f89406;"></span></td>
272
<td><code>@pink</code></td>
274
<td><span class="swatch" style="background-color: #c3325f;"></span></td>
277
<td><code>@purple</code></td>
279
<td><span class="swatch" style="background-color: #7a43b6;"></span></td>
290
<table class="table table-bordered table-striped">
293
<td class="span3"><code>@primaryButtonBackground</code></td>
294
<td><code>@linkColor</code></td>
295
<td class="swatch-col"><span class="swatch" style="background-color: #08c;"></span></td>
300
<table class="table table-bordered table-striped">
303
<td class="span3"><code>@placeholderText</code></td>
304
<td><code>@grayLight</code></td>
305
<td class="swatch-col"><span class="swatch" style="background-color: #999;"></span></td>
310
<table class="table table-bordered table-striped">
313
<td class="span3"><code>@navbarHeight</code></td>
315
<td class="swatch-col"></td>
318
<td><code>@navbarBackground</code></td>
319
<td><code>@grayDarker</code></td>
320
<td><span class="swatch" style="background-color: #222;"></span></td>
323
<td><code>@navbarBackgroundHighlight</code></td>
324
<td><code>@grayDark</code></td>
325
<td><span class="swatch" style="background-color: #333;"></span></td>
328
<td><code>@navbarText</code></td>
329
<td><code>@grayLight</code></td>
330
<td><span class="swatch" style="background-color: #999;"></span></td>
333
<td><code>@navbarLinkColor</code></td>
334
<td><code>@grayLight</code></td>
335
<td><span class="swatch" style="background-color: #999;"></span></td>
338
<td><code>@navbarLinkColorHover</code></td>
339
<td><code>@white</code></td>
340
<td><span class="swatch swatch-bordered" style="background-color: #fff;"></span></td>
346
<h4>Form states and alerts</h4>
347
<table class="table table-bordered table-striped">
350
<td class="span3"><code>@warningText</code></td>
352
<td><span class="swatch" style="background-color: #c09853;"></span></td>
355
<td><code>@warningBackground</code></td>
357
<td class="swatch-col"><span class="swatch" style="background-color: #f3edd2;"></span></td>
360
<td><code>@errorText</code></td>
362
<td><span class="swatch" style="background-color: #b94a48;"></span></td>
365
<td><code>@errorBackground</code></td>
367
<td><span class="swatch" style="background-color: #f2dede;"></span></td>
370
<td><code>@successText</code></td>
372
<td><span class="swatch" style="background-color: #468847;"></span></td>
375
<td><code>@successBackground</code></td>
377
<td><span class="swatch" style="background-color: #dff0d8;"></span></td>
380
<td><code>@infoText</code></td>
382
<td><span class="swatch" style="background-color: #3a87ad;"></span></td>
385
<td><code>@infoBackground</code></td>
387
<td><span class="swatch" style="background-color: #d9edf7;"></span></td>
399
================================================== -->
400
<section id="mixins">
401
<div class="page-header">
402
<h1>Bootstrap mixins <small></small></h1>
404
<h2>About mixins</h2>
407
<h3>Basic mixins</h3>
408
<p>A basic mixin is essentially an include or a partial for a snippet of CSS. They're written just like a CSS class and can be called anywhere.</p>
409
<pre class="prettyprint linenums">
414
</div><!-- /span4 -->
416
<h3>Parametric mixins</h3>
417
<p>A parametric mixin is just like a basic mixin, but it also accepts parameters (hence the name) with optional default values.</p>
418
<pre class="prettyprint linenums">
423
</div><!-- /span4 -->
425
<h3>Easily add your own</h3>
426
<p>Nearly all of Bootstrap's mixins are stored in mixins.less, a wonderful utility .less file that enables you to use a mixin in any of the .less files in the toolkit.</p>
427
<p>So, go ahead and use the existing ones or feel free to add your own as you need.</p>
428
</div><!-- /span4 -->
430
<h2>Included mixins</h2>
432
<table class="table table-bordered table-striped">
435
<th class="span4">Mixin</th>
442
<td><code>.clearfix()</code></td>
443
<td><em class="muted">none</em></td>
444
<td>Add to any parent to clear floats within</td>
447
<td><code>.tab-focus()</code></td>
448
<td><em class="muted">none</em></td>
449
<td>Apply the Webkit focus style and round Firefox outline</td>
452
<td><code>.center-block()</code></td>
453
<td><em class="muted">none</em></td>
454
<td>Auto center a block-level element using <code>margin: auto</code></td>
457
<td><code>.ie7-inline-block()</code></td>
458
<td><em class="muted">none</em></td>
459
<td>Use in addition to regular <code>display: inline-block</code> to get IE7 support</td>
462
<td><code>.size()</code></td>
463
<td><code>@height: 5px, @width: 5px</code></td>
464
<td>Quickly set the height and width on one line</td>
467
<td><code>.square()</code></td>
468
<td><code>@size: 5px</code></td>
469
<td>Builds on <code>.size()</code> to set the width and height as same value</td>
472
<td><code>.opacity()</code></td>
473
<td><code>@opacity: 100</code></td>
474
<td>Set, in whole numbers, the opacity percentage (e.g., "50" or "75")</td>
479
<table class="table table-bordered table-striped">
482
<th class="span4">Mixin</th>
489
<td><code>.placeholder()</code></td>
490
<td><code>@color: @placeholderText</code></td>
491
<td>Set the <code>placeholder</code> text color for inputs</td>
496
<table class="table table-bordered table-striped">
499
<th class="span4">Mixin</th>
506
<td><code>#font > #family > .serif()</code></td>
507
<td><em class="muted">none</em></td>
508
<td>Make an element use a serif font stack</td>
511
<td><code>#font > #family > .sans-serif()</code></td>
512
<td><em class="muted">none</em></td>
513
<td>Make an element use a sans-serif font stack</td>
516
<td><code>#font > #family > .monospace()</code></td>
517
<td><em class="muted">none</em></td>
518
<td>Make an element use a monospace font stack</td>
521
<td><code>#font > .shorthand()</code></td>
522
<td><code>@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight</code></td>
523
<td>Easily set font size, weight, and leading</td>
526
<td><code>#font > .serif()</code></td>
527
<td><code>@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight</code></td>
528
<td>Set font family to serif, and control size, weight, and leading</td>
531
<td><code>#font > .sans-serif()</code></td>
532
<td><code>@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight</code></td>
533
<td>Set font family to sans-serif, and control size, weight, and leading</td>
536
<td><code>#font > .monospace()</code></td>
537
<td><code>@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight</code></td>
538
<td>Set font family to monospace, and control size, weight, and leading</td>
543
<table class="table table-bordered table-striped">
546
<th class="span4">Mixin</th>
553
<td><code>.container-fixed()</code></td>
554
<td><em class="muted">none</em></td>
555
<td>Create a horizontally centered container for holding your content</td>
558
<td><code>#grid > .core()</code></td>
559
<td><code>@gridColumnWidth, @gridGutterWidth</code></td>
560
<td>Generate a pixel grid system (container, row, and columns) with <em>n</em> columns and <em>x</em> pixel wide gutter</td>
563
<td><code>#grid > .fluid()</code></td>
564
<td><code>@fluidGridColumnWidth, @fluidGridGutterWidth</code></td>
565
<td>Generate a precent grid system with <em>n</em> columns and <em>x</em> % wide gutter</td>
569
<h3>CSS3 properties</h3>
570
<table class="table table-bordered table-striped">
573
<th class="span3">Mixin</th>
580
<td><code>.border-radius()</code></td>
581
<td><code>@radius: 5px</code></td>
582
<td>Round the corners of an element. Can be a single value or four space-separated values</td>
585
<td><code>.box-shadow()</code></td>
586
<td><code>@shadow: 0 1px 3px rgba(0,0,0,.25)</code></td>
587
<td>Add a drop shadow to an element</td>
590
<td><code>.transition()</code></td>
591
<td><code>@transition</code></td>
592
<td>Add CSS3 transition effect (e.g., <code>all .2s linear</code>)</td>
595
<td><code>.rotate()</code></td>
596
<td><code>@degrees</code></td>
597
<td>Rotate an element <em>n</em> degrees</td>
600
<td><code>.scale()</code></td>
601
<td><code>@ratio</code></td>
602
<td>Scale an element to <em>n</em> times its original size</td>
605
<td><code>.translate()</code></td>
606
<td><code>@x: 0, @y: 0</code></td>
607
<td>Move an element on the x and y planes</td>
610
<td><code>.background-clip()</code></td>
611
<td><code>@clip</code></td>
612
<td>Crop the background of an element (useful for <code>border-radius</code>)</td>
615
<td><code>.background-size()</code></td>
616
<td><code>@size</code></td>
617
<td>Control the size of background images via CSS3</td>
620
<td><code>.box-sizing()</code></td>
621
<td><code>@boxmodel</code></td>
622
<td>Change the box model for an element (e.g., <code>border-box</code> for a full-width <code>input</code>)</td>
625
<td><code>.user-select()</code></td>
626
<td><code>@select</code></td>
627
<td>Control cursor selection of text on a page</td>
630
<td><code>.resizable()</code></td>
631
<td><code>@direction: both</code></td>
632
<td>Make any element resizable on the right and bottom</td>
635
<td><code>.content-columns()</code></td>
636
<td><code>@columnCount, @columnGap: @gridColumnGutter</code></td>
637
<td>Make the content of any element use CSS3 columns</td>
641
<h3>Backgrounds and gradients</h3>
642
<table class="table table-bordered table-striped">
645
<th class="span4">Mixin</th>
652
<td><code>#translucent > .background()</code></td>
653
<td><code>@color: @white, @alpha: 1</code></td>
654
<td>Give an element a translucent background color</td>
657
<td><code>#translucent > .border()</code></td>
658
<td><code>@color: @white, @alpha: 1</code></td>
659
<td>Give an element a translucent border color</td>
662
<td><code>#gradient > .vertical()</code></td>
663
<td><code>@startColor, @endColor</code></td>
664
<td>Create a cross-browser vertical background gradient</td>
667
<td><code>#gradient > .horizontal()</code></td>
668
<td><code>@startColor, @endColor</code></td>
669
<td>Create a cross-browser horizontal background gradient</td>
672
<td><code>#gradient > .directional()</code></td>
673
<td><code>@startColor, @endColor, @deg</code></td>
674
<td>Create a cross-browser directional background gradient</td>
677
<td><code>#gradient > .vertical-three-colors()</code></td>
678
<td><code>@startColor, @midColor, @colorStop, @endColor</code></td>
679
<td>Create a cross-browser three-color background gradient</td>
682
<td><code>#gradient > .radial()</code></td>
683
<td><code>@innerColor, @outerColor</code></td>
684
<td>Create a cross-browser radial background gradient</td>
687
<td><code>#gradient > .striped()</code></td>
688
<td><code>@color, @angle</code></td>
689
<td>Create a cross-browser striped background gradient</td>
692
<td><code>#gradientBar()</code></td>
693
<td><code>@primaryColor, @secondaryColor</code></td>
694
<td>Used for buttons to assign a gradient and slightly darker border</td>
702
<!-- COMPILING LESS AND BOOTSTRAP
703
================================================== -->
704
<section id="compiling">
705
<div class="page-header">
706
<h1>Compiling Bootstrap with LESS</h1>
708
<div class="alert alert-info">
709
<strong>Note:</strong> If you're submitting a pull request to GitHub with modified CSS, you <strong>must</strong> recompile the CSS via any of these methods.
711
<h2>Tools for compiling</h2>
714
<h3>Node with makefile</h3>
715
<p>Install the LESS command line compiler and uglify-js globally with npm by running the following command:</p>
716
<pre>$ npm install -g less uglify-js</pre>
717
<p>Once installed just run <code>make</code> from the root of your bootstrap directory and you're all set.</p>
718
<p>Additionally, if you have <a href="https://github.com/mynyml/watchr">watchr</a> installed, you may run <code>make watch</code> to have bootstrap automatically rebuilt every time you edit a file in the bootstrap lib (this isn't required, just a convenience method).</p>
719
</div><!-- /span4 -->
721
<h3>Command line</h3>
722
<p>Install the LESS command line tool via Node and run the following command:</p>
723
<pre>$ lessc ./lib/bootstrap.less > bootstrap.css</pre>
724
<p>Be sure to include <code>--compress</code> in that command if you're trying to save some bytes!</p>
725
</div><!-- /span4 -->
728
<p><a href="http://lesscss.org/">Download the latest Less.js</a> and include the path to it (and Bootstrap) in the <code><head></code>.</p>
729
<pre class="prettyprint">
730
<link rel="stylesheet/less" href="/path/to/bootstrap.less">
731
<script src="/path/to/less.js"></script>
733
<p>To recompile the .less files, just save them and reload your page. Less.js compiles them and stores them in local storage.</p>
734
</div><!-- /span4 -->
738
<h3>Unofficial Mac app</h3>
739
<p><a href="http://incident57.com/less/">The unofficial Mac app</a> watches directories of .less files and compiles the code to local files after every save of a watched .less file.</p>
740
<p>If you like, you can toggle preferences in the app for automatic minifying and which directory the compiled files end up in.</p>
741
</div><!-- /span4 -->
743
<h3>More Mac apps</h3>
744
<h4><a href="http://crunchapp.net/" target="_blank">Crunch</a></h4>
745
<p>Crunch is a great looking LESS editor and compiler built on Adobe Air.</p>
746
<h4><a href="http://incident57.com/codekit/" target="_blank">CodeKit</a></h4>
747
<p>Created by the same guy as the unofficial Mac app, CodeKit is a Mac app that compiles LESS, SASS, Stylus, and CoffeeScript.</p>
748
<h4><a href="http://wearekiss.com/simpless" target="_blank">Simpless</a></h4>
749
<p>Mac, Linux, and PC app for drag and drop compiling of LESS files. Plus, the <a href="https://github.com/Paratron/SimpLESS" target="_blank">source code is on GitHub</a>.</p>
750
</div><!-- /span4 -->
756
================================================== -->
757
<footer class="footer">
758
<p class="pull-right"><a href="#">Back to top</a></p>
759
<p>Designed and built with all the love in the world <a href="http://twitter.com/twitter" target="_blank">@twitter</a> by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
760
<p>Code licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>. Documentation licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
761
<p>Icons from <a href="http://glyphicons.com">Glyphicons Free</a>, licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
764
</div><!-- /container -->
769
================================================== -->
770
<!-- Placed at the end of the document so the pages load faster -->
771
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
772
<script src="assets/js/jquery.js"></script>
773
<script src="assets/js/google-code-prettify/prettify.js"></script>
774
<script src="assets/js/bootstrap-transition.js"></script>
775
<script src="assets/js/bootstrap-alert.js"></script>
776
<script src="assets/js/bootstrap-modal.js"></script>
777
<script src="assets/js/bootstrap-dropdown.js"></script>
778
<script src="assets/js/bootstrap-scrollspy.js"></script>
779
<script src="assets/js/bootstrap-tab.js"></script>
780
<script src="assets/js/bootstrap-tooltip.js"></script>
781
<script src="assets/js/bootstrap-popover.js"></script>
782
<script src="assets/js/bootstrap-button.js"></script>
783
<script src="assets/js/bootstrap-collapse.js"></script>
784
<script src="assets/js/bootstrap-carousel.js"></script>
785
<script src="assets/js/bootstrap-typeahead.js"></script>
786
<script src="assets/js/application.js"></script>