Förlänger Bootstrap

Utöka Bootstrap för att dra nytta av inkluderade stilar och komponenter, såväl som MINDRE variabler och mixins.

MINDRE CSS

Bootstrap är gjord med LESS som kärna, ett dynamiskt stilmallsspråk skapat av vår gode vän, Alexis Sellier . Det gör att utveckla systembaserad CSS snabbare, enklare och roligare.

Varför MINDRE?

En av Bootstraps skapare skrev ett snabbt blogginlägg om detta , sammanfattat här:

  • Bootstrap kompilerar snabbare ~6x snabbare med Less jämfört med Sass
  • Mindre skrivs i JavaScript, vilket gör det lättare för oss att dyka in och lappa jämfört med Ruby med Sass.
  • Mindre är mer; vi vill känna att vi skriver CSS och gör Bootstrap tillgänglig för alla.

Vad ingår?

Som en förlängning av CSS innehåller LESS variabler, mixins för återanvändbara kodavsnitt, operationer för enkel matematik, kapsling och till och med färgfunktioner.

Läs mer

Besök den officiella webbplatsen på http://lesscss.org/ för att lära dig mer.

Eftersom vår CSS är skriven med Less och använder variabler och mixins, måste den kompileras för slutlig produktionsimplementering. Här är hur.

Obs: Om du skickar en pull-begäran till GitHub med modifierad CSS, måste du kompilera om CSS via någon av dessa metoder.

Verktyg för att kompilera

Kommandorad

Follow the instructions in the project readme on GitHub for compiling via command line.

JavaScript

Download the latest Less.js and include the path to it (and Bootstrap) in the <head>.

<link rel="stylesheet/less" href="/path/to/bootstrap.less">
<script src="/path/to/less.js"></script>

To recompile the .less files, just save them and reload your page. Less.js compiles them and stores them in local storage.

Unofficial Mac app

The unofficial Mac app watches directories of .less files and compiles the code to local files after every save of a watched .less file. If you like, you can toggle preferences in the app for automatic minifying and which directory the compiled files end up in.

More apps

Crunch

Crunch is a great looking LESS editor and compiler built on Adobe Air.

CodeKit

Created by the same guy as the unofficial Mac app, CodeKit is a Mac app that compiles LESS, SASS, Stylus, and CoffeeScript.

Simpless

Mac, Linux, and Windows app for drag and drop compiling of LESS files. Plus, the source code is on GitHub.

Quickly start any web project by dropping in the compiled or minified CSS and JS. Layer on custom styles separately for easy upgrades and maintenance moving forward.

Setup file structure

Download the latest compiled Bootstrap and place into your project. For example, you might have something like this:

   app/
       layouts/
       templates/
   public/
       css/
           bootstrap.min.css
       js/
           bootstrap.min.js
       img/
           glyphicons-halflings.png
           glyphicons-halflings-white.png

Utilize starter template

Copy the following base HTML to get started.

  1. <html>
  2. <head>
  3. <title>Bootstrap 101 Template</title>
  4. <!-- Bootstrap -->
  5. <link href="public/css/bootstrap.min.css" rel="stylesheet">
  6. </head>
  7. <body>
  8. <h1>Hello, world!</h1>
  9. <!-- Bootstrap -->
  10. <script src="public/js/bootstrap.min.js"></script>
  11. </body>
  12. </html>

Layer on custom code

Work in your custom CSS, JS, and more as necessary to make Bootstrap your own with your own separate CSS and JS files.

  1. <html>
  2. <head>
  3. <title>Bootstrap 101 Template</title>
  4. <!-- Bootstrap -->
  5. <link href="public/css/bootstrap.min.css" rel="stylesheet">
  6. <!-- Project -->
  7. <link href="public/css/application.css" rel="stylesheet">
  8. </head>
  9. <body>
  10. <h1> Hej världen! </h1>
  11. <!-- Bootstrap -->
  12. <script src = "public/js/bootstrap.min.js" ></script>
  13. <!-- Projekt -->
  14. <script src = "public/js/application.js" ></script>
  15. </body>
  16. </html>