2012-01-25 03:26:45 +01:00
<div class="alert">
2012-01-25 02:14:19 +01:00
<strong>Heads up!</strong> This page is still under construction and is missing plenty of documentation. Hang tight!
</div>
2012-01-23 23:14:16 +01:00
<!-- Masthead
================================================== -->
<header class="jumbotron subhead" id="overview">
2012-01-24 22:57:44 +01:00
<h1>{{_i}}Using LESS with Bootstrap{{/i}}</h1>
<p class="lead">{{_i}}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.{{/i}}</p>
2012-01-25 01:07:30 +01:00
<ul class="nav pills">
<li><a href="./less.html#builtWith">{{_i}}Built with Less{{/i}}</a></li>
<li><a href="./less.html#variables">{{_i}}Variables{{/i}}</a></li>
<li><a href="./less.html#mixins">{{_i}}Mixins{{/i}}</a></li>
<li><a href="./less.html#compiling">{{_i}}Compiling Bootstrap{{/i}}</a></li>
</ul>
2012-01-23 23:14:16 +01:00
</header>
<!-- BUILT WITH LESS
================================================== -->
2012-01-25 01:07:30 +01:00
<section id="builtWith">
<div class="page-header">
<h1>{{_i}}Built with LESS{{/i}}</h1>
2012-01-23 23:14:16 +01:00
</div>
2012-01-25 01:07:30 +01:00
<div class="row">
<div class="span4">
<h3>{{_i}}Why LESS?{{/i}}</h3>
<p>{{_i}}Bootstrap is made with LESS at it's core, a dynamic stylesheet language created by <a href="http://cloudhead.io">Alexis Sellier</a>. It makes developing systems-based CSS faster, easier, and more fun.{{/i}}</p>
</div>
<div class="span4">
<h3>{{_i}}What's included?{{/i}}</h3>
<p>{{_i}}As an extension of CSS, LESS includes variables, mixins for reusable snippets of code, operations for simple math, nesting, and even color functions.{{/i}}</p>
</div>
<div class="span4">
<h3>{{_i}}Learn more{{/i}}</h3>
<img style="float: right; height: 36px;" src="assets/img/less-logo-large.png" alt="LESS CSS">
<p>{{_i}}Visit the official website at <a href="http://lesscss.org">http://lesscss.org</a> to learn more.{{/i}}</p>
</div>
2012-01-23 23:14:16 +01:00
</div>
2012-01-25 01:07:30 +01:00
<div class="row">
<div class="span4">
<h3>{{_i}}Variables{{/i}}</h3>
<p>{{_i}}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.{{/i}}</p>
</div>
<div class="span4">
<h3>{{_i}}Mixins{{/i}}</h3>
<p>{{_i}}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.{{/i}}</p>
</div>
<div class="span4">
<h3>{{_i}}Operations{{/i}}</h3>
<p>{{_i}}Make your grid, leading, and more super flexible by doing the math on the fly with operations. Multiple, divide, add, and subtract your way to CSS sanity.{{/i}}</p>
</div>
2012-01-23 23:14:16 +01:00
</div>
2012-01-25 01:07:30 +01:00
</section>
2012-01-23 23:14:16 +01:00
<!-- VARIABLES
================================================== -->
2012-01-25 01:07:30 +01:00
<section id="variables">
<div class="page-header">
<h1>{{_i}}Variables <small>from variables.less</small>{{/i}}</h1>
2012-01-23 23:14:16 +01:00
</div>
2012-01-25 01:07:30 +01:00
<h3>{{_i}}Hyperlinks{{/i}}</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="span2">{{_i}}Variable{{/i}}</th>
<th>{{_i}}Value{{/i}}</th>
<th>{{_i}}Usage{{/i}}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@linkColor</code></td>
<td>#08c</td>
<td>{{_i}}Default link text color{{/i}}</td>
</tr>
<tr>
<td><code>@linkColorHover</code></td>
<td><code>darken(@linkColor, 15%)</code></td>
<td>{{_i}}Default link text hover color{{/i}}</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="span6">
<h3>{{_i}}Grayscale colors{{/i}}</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="span2">{{_i}}Variable{{/i}}</th>
<th>{{_i}}Value{{/i}}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@black</code></td>
<td>#000</td>
</tr>
<tr>
<td><code>@grayDarker</code></td>
2012-01-25 01:54:35 +01:00
<td>#222</td>
2012-01-25 01:07:30 +01:00
</tr>
<tr>
<td><code>@grayDark</code></td>
2012-01-25 01:54:35 +01:00
<td>#333</td>
2012-01-25 01:07:30 +01:00
</tr>
<tr>
<td><code>@gray</code></td>
2012-01-25 01:54:35 +01:00
<td>#555</td>
2012-01-25 01:07:30 +01:00
</tr>
<tr>
<td><code>@grayLight</code></td>
2012-01-25 01:54:35 +01:00
<td>#999</td>
2012-01-25 01:07:30 +01:00
</tr>
<tr>
<td><code>@grayLighter</code></td>
2012-01-25 01:54:35 +01:00
<td>#eee</td>
2012-01-25 01:07:30 +01:00
</tr>
<tr>
<td><code>@white</code></td>
<td>#fff</td>
</tr>
</tbody>
</table>
</div>
<div class="span6">
<h3>{{_i}}Accent colors{{/i}}</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="span2">{{_i}}Variable{{/i}}</th>
<th>{{_i}}Value{{/i}}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@blue</code></td>
<td>#049cdb</td>
</tr>
<tr>
<td><code>@green</code></td>
<td>#46a546</td>
</tr>
<tr>
<td><code>@red</code></td>
<td>#9d261d</td>
</tr>
<tr>
<td><code>@yellow</code></td>
<td>#ffc40d</td>
</tr>
<tr>
<td><code>@orange</code></td>
<td>#f89406</td>
</tr>
<tr>
<td><code>@pink</code></td>
<td>#c3325f</td>
</tr>
<tr>
<td><code>@purple</code></td>
<td>#7a43b6</td>
</tr>
</tbody>
</table>
</div>
</div> <!-- /row -->
<div class="row">
<div class="span6">
<h3>{{_i}}Grid system{{/i}}</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="span2">{{_i}}Variable{{/i}}</th>
<th>{{_i}}Value{{/i}}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@gridColumns</code></td>
<td>12</td>
</tr>
<tr>
<td><code>@gridColumnWidth</code></td>
<td>60px</td>
</tr>
<tr>
<td><code>@gridGutterWidth</code></td>
<td>20px</td>
</tr>
<tr>
<td><code>@siteWidth</code></td>
<td><code>(@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1))</code></td>
</tr>
</tbody>
</table>
</div>
<div class="span6">
<h3>{{_i}}Typography{{/i}}</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="span2">{{_i}}Variable{{/i}}</th>
<th>{{_i}}Value{{/i}}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@baseFontSize</code></td>
<td>13px</td>
</tr>
<tr>
<td><code>@baseFontFamily</code></td>
<td><code>"Helvetica Neue", Helvetica, Arial, sans-serif</code></td>
<td></td>
</tr>
<tr>
<td><code>@baseLineHeight</code></td>
<td>18px</td>
</tr>
</tbody>
</table>
</div>
</div> <!-- /row -->
2012-01-25 01:54:35 +01:00
<h3>{{_i}}Components{{/i}}</h3>
2012-01-25 02:14:19 +01:00
<div class="row">
<div class="span6">
<h4>Buttons</h4>
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td class="span3"><code>@primaryButtonColor</code></td>
<td><code>@blue</code></td>
</tr>
</tbody>
</table>
<h4>Forms</h4>
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td class="span3"><code>@placeholderText</code></td>
<td><code>@grayLight</code></td>
</tr>
</tbody>
</table>
<h4>Navbar</h4>
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td class="span3"><code>@navbarHeight</code></td>
<td>40px</td>
</tr>
<tr>
<td><code>@navbarBackground</code></td>
<td><code>@grayDarker</code></td>
</tr>
<tr>
<td><code>@navbarBackgroundHighlight</code></td>
<td><code>@grayDark</code></td>
</tr>
</tbody>
</table>
</div>
<div class="span6">
<h4>Form states and alerts</h4>
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td class="span3"><code>@warningText</code></td>
<td>#f3edd2</td>
</tr>
<tr>
<td><code>@warningBackground</code></td>
<td>#c09853</td>
</tr>
<tr>
<td><code>@warningBorder</code></td>
<td>#f3edd2</td>
</tr>
<tr>
<td><code>@errorText</code></td>
<td>#b94a48</td>
</tr>
<tr>
<td><code>@errorBackground</code></td>
<td>#f2dede</td>
</tr>
<tr>
<td><code>@errorBorder</code></td>
<td>#e9c7c7</td>
</tr>
<tr>
<td><code>@successText</code></td>
<td>#468847</td>
</tr>
<tr>
<td><code>@successBackground</code></td>
<td>#dff0d8</td>
</tr>
<tr>
<td><code>@successBorder</code></td>
<td>#cfe8c4</td>
</tr>
<tr>
<td><code>@infoText</code></td>
<td>#3a87ad</td>
</tr>
<tr>
<td><code>@infoBackground</code></td>
<td>#d9edf7</td>
</tr>
<tr>
<td><code>@infoBorder</code></td>
<td>#bfe1f2</td>
</tr>
</tbody>
</table>
</div>
</div><!-- /row -->
2012-01-25 01:54:35 +01:00
2012-01-25 01:07:30 +01:00
</section>
2012-01-23 23:14:16 +01:00
<!-- MIXINS
================================================== -->
<div class="page-header" id="mixins">
2012-01-24 22:57:44 +01:00
<h1>{{_i}}Mixins <small>from mixins.less</small>{{/i}}</h1>
2012-01-23 23:14:16 +01:00
</div>
<!-- OPERATIONS
================================================== -->
<div class="page-header" id="operations">
2012-01-24 22:57:44 +01:00
<h1>{{_i}}Operations{{/i}}</h1>
2012-01-23 23:14:16 +01:00
</div>
<!-- COMPILING LESS AND BOOTSTRAP
================================================== -->
<div class="page-header" id="compiling">
2012-01-24 22:57:44 +01:00
<h1>{{_i}}Compiling LESS and Bootstrap{{/i}}</h1>
2012-01-23 23:14:16 +01:00
</div>
<!-- Using Bootstrap w/ Less
================================================== -->
<section id="less">
<div class="page-header">
2012-01-24 22:57:44 +01:00
<h1>{{_i}}Using Bootstrap with Less <small>Supercharge your CSS with variables, mixins, and functions</small>{{/i}}</h1>
2012-01-23 23:14:16 +01:00
</div>
<div class="row">
<div class="span3">
2012-01-24 22:57:44 +01:00
<p>{{_i}}Bootstrap was built with <a href="http://markdotto.com/bootstrap/">Preboot</a>, an open-source pack of mixins and variables to be used in conjunction with <a href="http://lesscss.org" target="_blank">Less</a>, a CSS preprocessor for faster and easier web development.{{/i}}</p>
<p>{{_i}}Check out how we used Preboot in Bootstrap and how you can make use of it should you choose to run Less on your next project.{{/i}}</p>
2012-01-23 23:14:16 +01:00
</div>
<div class="span9">
2012-01-24 22:57:44 +01:00
<h2>{{_i}}How to use it{{/i}}</h2>
<p>{{_i}}Use this option to make full use of Bootstrap’ s Less variables, mixins, and nesting in CSS via javascript in your browser.{{/i}}</p>
2012-01-23 23:14:16 +01:00
<pre class="prettyprint linenums">
<link rel="stylesheet/less" href="less/bootstrap.less" media="all" />
<script src="js/less-1.1.3.min.js"></script></pre>
2012-01-24 22:57:44 +01:00
<p>{{_i}}Not feeling the .js solution? <a href="http://incident57.com/less" target="_blank">Try the Less Mac app</a> or <a href="http://lesscss.org/#-client-side-usage" target="_blank">use Node.js</a> to compile when you deploy your code.{{/i}}</p>
2012-01-23 23:14:16 +01:00
2012-01-24 22:57:44 +01:00
<h2>{{_i}}What’ s included{{/i}}</h2>
<p>{{_i}}Here are some of the highlights of what’ s included in Twitter Bootstrap as part of Bootstrap. Head over to the Bootstrap website or Github project page to download and learn more.{{/i}}</p>
<h3>{{_i}}Variables{{/i}}</h3>
<p>{{_i}}Variables in Less are perfect for maintaining and updating your CSS headache free. When you want to change a color value or a frequently used value, update it in one spot and you’ re set.{{/i}}</p>
2012-01-23 23:14:16 +01:00
<pre class="prettyprint linenums">
// Links
@linkColor: #8b59c2;
@linkColorHover: darken(@linkColor, 10);
// Grays
@black: #000;
@grayDark: lighten(@black, 25%);
@gray: lighten(@black, 50%);
@grayLight: lighten(@black, 70%);
@grayLighter: lighten(@black, 90%);
@white: #fff;
// Accent Colors
@blue: #08b5fb;
@green: #46a546;
@red: #9d261d;
@yellow: #ffc40d;
@orange: #f89406;
@pink: #c3325f;
@purple: #7a43b6;
// Baseline grid
@basefont: 13px;
@baseline: 18px;
</pre>
2012-01-24 22:57:44 +01:00
<h3>{{_i}}Commenting{{/i}}</h3>
<p>{{_i}}Less also provides another style of commenting in addition to CSS’ s normal <code>/* ... */</code> syntax.{{/i}}</p>
2012-01-23 23:14:16 +01:00
<pre class="prettyprint linenums">
// This is a comment
/* This is also a comment */
</pre>
2012-01-24 22:57:44 +01:00
<h3>{{_i}}Mixins up the wazoo{{/i}}</h3>
<p>{{_i}}Mixins are basically includes or partials for CSS, allowing you to combine a block of code into one. They’ re great for vendor prefixed properties like <code>box-shadow</code>, cross-browser gradients, font stacks, and more. Below is a sample of the mixins that are included with Bootstrap.{{/i}}</p>
<h4>{{_i}}Font stacks{{/i}}</h4>
2012-01-23 23:14:16 +01:00
<pre class="prettyprint linenums">
#font {
.shorthand(@weight: normal, @size: 14px, @lineHeight: 20px) {
font-size: @size;
font-weight: @weight;
line-height: @lineHeight;
}
.sans-serif(@weight: normal, @size: 14px, @lineHeight: 20px) {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: @size;
font-weight: @weight;
line-height: @lineHeight;
}
...
}
</pre>
2012-01-24 22:57:44 +01:00
<h4>{{_i}}Gradients{{/i}}</h4>
2012-01-23 23:14:16 +01:00
<pre class="prettyprint linenums">
#gradient {
...
.vertical (@startColor: #555, @endColor: #333) {
background-color: @endColor;
background-repeat: repeat-x;
background-image: -khtml-gradient(linear, left top, left bottom, from(@startColor), to(@endColor)); // Konqueror
background-image: -moz-linear-gradient(@startColor, @endColor); // FF 3.6+
background-image: -ms-linear-gradient(@startColor, @endColor); // IE10
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, @startColor), color-stop(100%, @endColor)); // Safari 4+, Chrome 2+
background-image: -webkit-linear-gradient(@startColor, @endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(@startColor, @endColor); // Opera 11.10
background-image: linear-gradient(@startColor, @endColor); // The standard
}
...
}
</pre>
2012-01-24 22:57:44 +01:00
<h3>{{_i}}Operations{{/i}}</h3>
<p>{{_i}}Get fancy and perform some math to generate flexible and powerful mixins like the one below.{{/i}}</p>
2012-01-23 23:14:16 +01:00
<pre class="prettyprint linenums">
// Griditude
@gridColumns: 16;
@gridColumnWidth: 40px;
@gridGutterWidth: 20px;
@siteWidth: (@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1));
// Make some columns
.columns(@columnSpan: 1) {
width: (@gridColumnWidth * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1));
}
</pre>
2012-01-24 22:57:44 +01:00
<h2 id="compiling">{{_i}}Compiling Less{{/i}}</h2>
<p>{{_i}}After modifying the <code>.less</code> files in /lib/, you'll need to recompile them in order to regenerate the bootstrap-*.*.*.css and bootstrap-*.*.*.min.css files. If you're submitting a pull request to GitHub, you must always recompile.{{/i}}</p>
<h3>{{_i}}Ways to compile{{/i}}</h3>
2012-01-23 23:14:16 +01:00
<table class="table table-bordered table-striped">
<thead>
<tr>
2012-01-24 22:57:44 +01:00
<th style="width: 120px;">{{_i}}Method{{/i}}</th>
<th>{{_i}}Steps{{/i}}</th>
2012-01-23 23:14:16 +01:00
</tr>
</thead>
<tbody>
<tr>
2012-01-24 22:57:44 +01:00
<td>{{_i}}Node with makefile{{/i}}</td>
2012-01-23 23:14:16 +01:00
<td>
2012-01-24 22:57:44 +01:00
<p>{{_i}}Install the LESS command line compiler with npm by running the following command:{{/i}}</p>
2012-01-23 23:14:16 +01:00
<pre>$ npm install less</pre>
2012-01-24 22:57:44 +01:00
<p>{{_i}}Once installed just run <code>make</code> from the root of your bootstrap directory and you're all set.{{/i}}</p>
<p>{{_i}}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).{{/i}}</p>
2012-01-23 23:14:16 +01:00
</td>
</tr>
2012-01-24 22:57:44 +01:00
<td>{{_i}}Javascript{{/i}}</td>
2012-01-23 23:14:16 +01:00
<td>
2012-01-24 22:57:44 +01:00
<p>{{_i}}<a href="http://lesscss.org/">Download the latest Less.js</a> and include the path to it (and Bootstrap) in the <code><head></code>.{{/i}}</p>
2012-01-23 23:14:16 +01:00
<pre class="prettyprint">
<link rel="stylesheet/less" href="/path/to/bootstrap.less">
<script src="/path/to/less.js"></script>
</pre>
2012-01-24 22:57:44 +01:00
<p>{{_i}}To recompile the .less files, just save them and reload your page. Less.js compiles them and stores them in local storage.{{/i}}</p>
2012-01-23 23:14:16 +01:00
</td>
</tr>
<tr>
2012-01-24 22:57:44 +01:00
<td>{{_i}}Command line{{/i}}</td>
2012-01-23 23:14:16 +01:00
<td>
2012-01-24 22:57:44 +01:00
<p>{{_i}}Install the LESS command line tool via Node and run the following command:{{/i}}</p>
2012-01-23 23:14:16 +01:00
<pre>$ lessc ./lib/bootstrap.less > bootstrap.css</pre>
2012-01-24 22:57:44 +01:00
<p>{{_i}}Be sure to include <code>--compress</code> in that command if you're trying to save some bytes!{{/i}}</p>
2012-01-23 23:14:16 +01:00
</td>
</tr>
<tr>
2012-01-24 22:57:44 +01:00
<td><a href="http://incident57.com/less/" target="_blank">{{_i}}Unofficial Mac app{{/i}}</a></td>
2012-01-23 23:14:16 +01:00
<td>
2012-01-24 22:57:44 +01:00
<p>{{_i}}<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.{{/i}}</p>
<p>{{_i}}If you like, you can toggle preferences in the app for automatic minifying and which directory the compiled files end up in.{{/i}}</p>
2012-01-23 23:14:16 +01:00
</td>
</tr>
<tr>
<td><a href="http://crunchapp.net/" target="_blank">Crunch</a></td>
2012-01-24 22:57:44 +01:00
<td>{{_i}}Crunch is a great looking LESS editor and compiler built on Adobe Air.{{/i}}</td>
2012-01-23 23:14:16 +01:00
</tr>
<tr>
<td><a href="http://incident57.com/codekit/" target="_blank">CodeKit</a></td>
2012-01-24 22:57:44 +01:00
<td>{{_i}}Created by the same guy as the unofficial Mac app, CodeKit is a Mac app that compiles LESS, SASS, Stylus, and CoffeeScript.{{/i}}</td>
2012-01-23 23:14:16 +01:00
</tr>
<tr>
<td><a href="http://wearekiss.com/simpless" target="_blank">Simpless</a></td>
2012-01-24 22:57:44 +01:00
<td>{{_i}}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>.{{/i}}</td>
2012-01-23 23:14:16 +01:00
</tr>
</tbody>
</table>
</div>
</div>
</section>