less.html 27.19 KiB
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Bootstrap, from Twitter</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <!-- Le styles -->
    <link href="assets/css/bootstrap.css" rel="stylesheet">
    <link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="assets/css/docs.css" rel="stylesheet">
    <link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="assets/ico/favicon.ico">
    <link rel="apple-touch-icon" href="assets/ico/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="assets/ico/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="assets/ico/apple-touch-icon-114x114.png">
  </head>
  <body data-spy="scroll" data-target=".subnav" data-offset="50">
  <!-- Navbar
    ================================================== -->
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="brand" href="./index.html">Bootstrap</a>
          <ul class="nav">
            <li class="">
              <a href="./index.html">Overview</a>
            </li>
            <li class="">
              <a href="./scaffolding.html">Scaffolding</a>
            </li>
            <li class="">
              <a href="./base-css.html">Base CSS</a>
            </li>
            <li class="">
              <a href="./components.html">Components</a>
            </li>
            <li class="">
              <a href="./javascript.html">Javascript plugins</a>
            </li>
            <li class="active">
              <a href="./less.html">Using LESS</a>
            </li>
            <li class="">
              <a href="./download.html">Download</a>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="container">
<div class="alert">
  <strong>Heads up!</strong> This page is still under construction and is missing plenty of documentation. Hang tight!
</div>
<!-- Masthead
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
================================================== --> <header class="jumbotron subhead" id="overview"> <h1>Using LESS with Bootstrap</h1> <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> <div class="subnav"> <ul class="nav pills"> <li><a href="#builtWith">Built with Less</a></li> <li><a href="#variables">Variables</a></li> <li><a href="#mixins">Mixins</a></li> <li><a href="#compiling">Compiling Bootstrap</a></li> </ul> </div> </header> <!-- BUILT WITH LESS ================================================== --> <section id="builtWith"> <div class="page-header"> <h1>Built with LESS</h1> </div> <div class="row"> <div class="span4"> <h3>Why LESS?</h3> <p>Bootstrap is made with LESS at it's 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> </div> <div class="span4"> <h3>What's included?</h3> <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> </div> <div class="span4"> <h3>Learn more</h3> <img style="float: right; height: 36px;" src="assets/img/less-logo-large.png" alt="LESS CSS"> <p>Visit the official website at <a href="http://lesscss.org">http://lesscss.org</a> to learn more.</p> </div> </div> <div class="row"> <div class="span4"> <h3><a href="#variables">Variables</a></h3> <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&mdash;assign colors or pixel values as variables and change them once.</p> </div> <div class="span4"> <h3><a href="#mixins">Mixins</a></h3> <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> </div> <div class="span4"> <h3>Operations</h3> <p>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.</p> </div> </div> </section> <!-- VARIABLES ================================================== --> <section id="variables"> <div class="page-header"> <h1>Bootstrap variables <small></small></h1> </div> <h3>Hyperlinks</h3> <table class="table table-bordered table-striped"> <thead> <tr> <th class="span2">Variable</th> <th>Value</th> <th>Usage</th> </tr>
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
</thead> <tbody> <tr> <td><code>@linkColor</code></td> <td>#08c</td> <td>Default link text color</td> </tr> <tr> <td><code>@linkColorHover</code></td> <td><code>darken(@linkColor, 15%)</code></td> <td>Default link text hover color</td> </tr> </tbody> </table> <div class="row"> <div class="span6"> <h3>Grayscale colors</h3> <table class="table table-bordered table-striped"> <thead> <tr> <th class="span2">Variable</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td><code>@black</code></td> <td>#000</td> </tr> <tr> <td><code>@grayDarker</code></td> <td>#222</td> </tr> <tr> <td><code>@grayDark</code></td> <td>#333</td> </tr> <tr> <td><code>@gray</code></td> <td>#555</td> </tr> <tr> <td><code>@grayLight</code></td> <td>#999</td> </tr> <tr> <td><code>@grayLighter</code></td> <td>#eee</td> </tr> <tr> <td><code>@white</code></td> <td>#fff</td> </tr> </tbody> </table> </div> <div class="span6"> <h3>Accent colors</h3> <table class="table table-bordered table-striped"> <thead> <tr> <th class="span2">Variable</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td><code>@blue</code></td> <td>#049cdb</td>
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
</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>Grid system</h3> <table class="table table-bordered table-striped"> <thead> <tr> <th class="span2">Variable</th> <th>Value</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>Typography</h3> <table class="table table-bordered table-striped"> <thead> <tr> <th class="span2">Variable</th> <th>Value</th> </tr> </thead> <tbody> <tr>
281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
<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 --> <h3>Components</h3> <div class="row"> <div class="span6"> <h4>Buttons</h4> <table class="table table-bordered table-striped"> <tbody> <tr> <td class="span3"><code>@primaryButtonBackground</code></td> <td><code>@linkColor</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> <tr> <td><code>@navbarText</code></td> <td><code>@grayLight</code></td> </tr> <tr> <td><code>@navbarLinkColor</code></td> <td><code>@grayLight</code></td> </tr> <tr> <td><code>@navbarLinkColorHover</code></td> <td><code>@white</code></td> </tr> </tbody> </table> </div> <div class="span6"> <h4>Form states and alerts</h4>
351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
<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 --> </section> <!-- MIXINS ================================================== --> <section id="mixins"> <div class="page-header"> <h1>Bootstrap mixins <small></small></h1> </div> <h2>About mixins</h2> <div class="row"> <div class="span4"> <h3>Basic mixins</h3> <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>
421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
<pre class="prettyprint linenums"> .element { .clearfix(); } </pre> </div><!-- /span4 --> <div class="span4"> <h3>Parametric mixins</h3> <p>A parametric mixin is just like a basic mixin, but it also accepts parameters (hence the name) with optional default values.</p> <pre class="prettyprint linenums"> .element { .border-radius(4px); } </pre> </div><!-- /span4 --> <div class="span4"> <h3>Easily add your own</h3> <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> <p>So, go ahead and use the existing ones or feel free to add your own as you need.</p> </div><!-- /span4 --> </div><!-- /row --> <h2>Included mixins</h2> <h3>Utilities</h3> <table class="table table-bordered table-striped"> <thead> <tr> <th class="span4">Mixin</th> <th>Parameters</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td><code>.clearfix()</code></td> <td><em class="muted">none</em></td> <td>Add to any parent to clear floats within</td> </tr> <tr> <td><code>.center-block()</code></td> <td><em class="muted">none</em></td> <td>Auto center a block-level element using <code>margin: auto</code></td> </tr> <tr> <td><code>.ie7-inline-block()</code></td> <td><em class="muted">none</em></td> <td>Use in addition to regular <code>display: inline-block</code> to get IE7 support</td> </tr> <tr> <td><code>.size()</code></td> <td><code>@height: 5px, @width: 5px</code></td> <td>Quickly set the height and width on one line</td> </tr> <tr> <td><code>.square()</code></td> <td><code>@size: 5px</code></td> <td>Builds on <code>.size()</code> to set the width and height as same value</td> </tr> <tr> <td><code>.opacity()</code></td> <td><code>@opacity: 100</code></td> <td>Set, in whole numbers, the opacity percentage (e.g., "50" or "75")</td> </tr> </tbody> </table> <h3>Forms</h3> <table class="table table-bordered table-striped"> <thead> <tr> <th class="span4">Mixin</th> <th>Parameters</th>