Прилагодите и проширите Боотстрап помоћу ЛЕСС , ЦСС препроцесора, да бисте искористили предности променљивих, миксина и још много тога што се користи за прављење Боотстрап-овог ЦСС-а.
Боотстрап је направљен са ЛЕСС-ом у својој сржи, динамичким језиком стилова који је креирао наш добар пријатељ, Алекис Селлиер . То чини развој ЦСС заснованог на системима бржим, лакшим и забавнијим.
Као проширење ЦСС-а, ЛЕСС укључује променљиве, миксине за исечке кода за вишекратну употребу, операције за једноставну математику, гнежђење, па чак и функције боја.
Управљање бојама и вредностима пиксела у ЦСС-у може бити мало мука, обично пуно копирања и лепљења. Али не са ЛЕСС – доделите боје или вредности пиксела као променљиве и промените их једном.
Те три декларације радијуса границе које треба да направите у обичном старом ЦСС-у? Сада су сведене на један ред уз помоћ миксина, исечака кода које можете поново да користите било где.
Учините своју мрежу, водећи и супер флексибилнијом тако што ћете радити математику у ходу са операцијама. Множите, делите, сабирајте и одузимајте свој пут до ЦСС разума.
@linkColor |
#08ц | Подразумевана боја текста везе | |
@linkColorHover |
darken(@linkColor, 15%) |
Подразумевана боја текста везе |
@gridColumns |
12 |
@gridColumnWidth |
60пк |
@gridGutterWidth |
20пк |
@fluidGridColumnWidth |
6,382978723% |
@fluidGridGutterWidth |
2,127659574% |
@baseFontSize |
13пк |
@baseFontFamily |
"Helvetica Neue", Helvetica, Arial, sans-serif |
@baseLineHeight |
18пк |
@black |
#000 | |
@grayDarker |
#222 | |
@grayDark |
#333 | |
@gray |
#555 | |
@grayLight |
#999 | |
@grayLighter |
#еее | |
@white |
#ффф |
@blue |
#049цдб | |
@green |
#46а546 | |
@red |
#9д261д | |
@yellow |
#ффц40д | |
@orange |
#ф89406 | |
@pink |
#ц3325ф | |
@purple |
#7а43б6 |
@primaryButtonBackground |
@linkColor |
@placeholderText |
@grayLight |
@navbarHeight |
40пк | |
@navbarBackground |
@grayDarker |
|
@navbarBackgroundHighlight |
@grayDark |
|
@navbarText |
@grayLight |
|
@navbarLinkColor |
@grayLight |
|
@navbarLinkColorHover |
@white |
@warningText |
#ц09853 | |
@warningBackground |
#ф3едд2 | |
@errorText |
#б94а48 | |
@errorBackground |
#ф2деде | |
@successText |
#468847 | |
@successBackground |
#дфф0д8 | |
@infoText |
#3а87ад | |
@infoBackground |
#д9едф7 |
Основни микс је у суштини укључен или делимичан за исечак ЦСС-а. Написане су баш као ЦСС класа и могу се позвати било где.
- . елемент {
- . цлеарфик ();
- }
Параметарски миксин је као основни миксин, али такође прихвата параметре (отуда и име) са опционим подразумеваним вредностима.
- . елемент {
- . граница - радијус ( 4пк );
- }
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.
So, go ahead and use the existing ones or feel free to add your own as you need.
Mixin | Parameters | Usage |
---|---|---|
.clearfix() |
none | Add to any parent to clear floats within |
.tab-focus() |
none | Apply the Webkit focus style and round Firefox outline |
.center-block() |
none | Auto center a block-level element using margin: auto |
.ie7-inline-block() |
none | Use in addition to regular display: inline-block to get IE7 support |
.size() |
@height: 5px, @width: 5px |
Quickly set the height and width on one line |
.square() |
@size: 5px |
Builds on .size() to set the width and height as same value |
.opacity() |
@opacity: 100 |
Set, in whole numbers, the opacity percentage (e.g., "50" or "75") |
Mixin | Parameters | Usage |
---|---|---|
.placeholder() |
@color: @placeholderText |
Set the placeholder text color for inputs |
Mixin | Parameters | Usage |
---|---|---|
#font > #family > .serif() |
none | Make an element use a serif font stack |
#font > #family > .sans-serif() |
none | Make an element use a sans-serif font stack |
#font > #family > .monospace() |
none | Make an element use a monospace font stack |
#font > .shorthand() |
@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight |
Easily set font size, weight, and leading |
#font > .serif() |
@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight |
Set font family to serif, and control size, weight, and leading |
#font > .sans-serif() |
@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight |
Set font family to sans-serif, and control size, weight, and leading |
#font > .monospace() |
@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight |
Set font family to monospace, and control size, weight, and leading |
Mixin | Parameters | Usage |
---|---|---|
.container-fixed() |
none | Create a horizontally centered container for holding your content |
#grid > .core() |
@gridColumnWidth, @gridGutterWidth |
Generate a pixel grid system (container, row, and columns) with n columns and x pixel wide gutter |
#grid > .fluid() |
@fluidGridColumnWidth, @fluidGridGutterWidth |
Generate a precent grid system with n columns and x % wide gutter |
Mixin | Parameters | Usage |
---|---|---|
.border-radius() |
@radius: 5px |
Round the corners of an element. Can be a single value or four space-separated values |
.box-shadow() |
@shadow: 0 1px 3px rgba(0,0,0,.25) |
Add a drop shadow to an element |
.transition() |
@transition |
Add CSS3 transition effect (e.g., all .2s linear ) |
.rotate() |
@degrees |
Rotate an element n degrees |
.scale() |
@ratio |
Scale an element to n times its original size |
.translate() |
@x: 0, @y: 0 |
Move an element on the x and y planes |
.background-clip() |
@clip |
Crop the background of an element (useful for border-radius ) |
.background-size() |
@size |
Control the size of background images via CSS3 |
.box-sizing() |
@boxmodel |
Change the box model for an element (e.g., border-box for a full-width input ) |
.user-select() |
@select |
Control cursor selection of text on a page |
.resizable() |
@direction: both |
Make any element resizable on the right and bottom |
.content-columns() |
@columnCount, @columnGap: @gridColumnGutter |
Make the content of any element use CSS3 columns |
Mixin | Parameters | Usage |
---|---|---|
#translucent > .background() |
@color: @white, @alpha: 1 |
Give an element a translucent background color |
#translucent > .border() |
@color: @white, @alpha: 1 |
Give an element a translucent border color |
#gradient > .vertical() |
@startColor, @endColor |
Create a cross-browser vertical background gradient |
#gradient > .horizontal() |
@startColor, @endColor |
Create a cross-browser horizontal background gradient |
#gradient > .directional() |
@startColor, @endColor, @deg |
Create a cross-browser directional background gradient |
#gradient > .vertical-three-colors() |
@startColor, @midColor, @colorStop, @endColor |
Create a cross-browser three-color background gradient |
#gradient > .radial() |
@innerColor, @outerColor |
Create a cross-browser radial background gradient |
#gradient > .striped() |
@color, @angle |
Create a cross-browser striped background gradient |
#gradientBar() |
@primaryColor, @secondaryColor |
Used for buttons to assign a gradient and slightly darker border |
Install the LESS command line compiler and uglify-js globally with npm by running the following command:
$ npm install -g less 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 ./lib/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.
Направио је исти тип као и незваничну Мац апликацију, ЦодеКит је Мац апликација која компајлира ЛЕСС, САСС, Стилус и ЦоффееСцрипт.
Мац, Линук и ПЦ апликација за превлачење и испуштање компајлирања МАЊЕ датотека. Осим тога, изворни код је на ГитХуб-у .