Extindeți Bootstrap pentru a profita de stilurile și componentele incluse, precum și de variabile și mixuri LESS.
Bootstrap este creat cu LESS la bază, un limbaj dinamic pentru foi de stil creat de bunul nostru prieten, Alexis Sellier . Face dezvoltarea CSS bazate pe sisteme mai rapidă, mai ușoară și mai distractivă.
Unul dintre creatorii Bootstrap a scris o postare rapidă pe blog despre aceasta , rezumată aici:
Ca o extensie a CSS, LESS include variabile, mixuri pentru fragmente de cod reutilizabile, operații pentru matematică simplă, imbricare și chiar funcții de culoare.
Vizitați site-ul oficial la http://lesscss.org/ pentru a afla mai multe.
Deoarece CSS-ul nostru este scris cu Less și utilizează variabile și mixuri, trebuie să fie compilat pentru implementarea finală a producției. Iată cum.
Install the LESS command line compiler, JSHint, Recess, and uglify-js globally with npm by running the following command:
$ npm install -g less jshint recess uglify-js
Once installed just run make
from the root of your bootstrap directory and you're all set.
Additionally, if you have watchr installed, you may run make watch
to have bootstrap automatically rebuilt every time you edit a file in the bootstrap lib (this isn't required, just a convenience method).
Install the LESS command line tool via Node and run the following command:
$ lessc ./less/bootstrap.less > bootstrap.css
Be sure to include --compress
in that command if you're trying to save some bytes!
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.
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.
Crunch is a great looking LESS editor and compiler built on Adobe Air.
Created by the same guy as the unofficial Mac app, CodeKit is a Mac app that compiles LESS, SASS, Stylus, and CoffeeScript.
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.
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
Copy the following base HTML to get started.
- <html>
- <head>
- <title>Bootstrap 101 Template</title>
- <!-- Bootstrap -->
- <link href="public/css/bootstrap.min.css" rel="stylesheet">
- </head>
- <body>
- <h1>Hello, world!</h1>
- <!-- Bootstrap -->
- <script src="public/js/bootstrap.min.js"></script>
- </body>
- </html>
Work in your custom CSS, JS, and more as necessary to make Bootstrap your own with your own separate CSS and JS files.
- <html>
- <head>
- <title>Bootstrap 101 Template</title>
- <!-- Bootstrap -->
- <link href="public/css/bootstrap.min.css" rel="stylesheet">
- <!-- Project -->
- <link href="public/css/application.css" rel="stylesheet">
- </head>
- <body>
- <h1>Hello, world!</h1>
- <!-- Bootstrap -->
- <script src="public/js/bootstrap.min.js"></script>
- <!-- Project -->
- <script src="public/js/application.js"></script>
- </body>
- </html>