Enza ngendlela oyifisayo futhi wandise i-Bootstrap nge- LESS , i-preprocessor ye-CSS, ukuze usebenzise okuguquguqukayo, imiksi, nokunye okusetshenziselwa ukwakha i-CSS ye-Bootstrap.
I-Bootstrap yenziwe nge-LESS kumongo wayo, ulimi lweshidi lesitayela oluguqukayo oludalwe umngane wethu omkhulu, u- Alexis Sellier . Kwenza ukuthuthukiswa kwe-CSS okusekelwe kumasistimu kusheshe, kube lula, futhi kube mnandi kakhulu.
Njengesandiso se-CSS, i-LESS ihlanganisa okuguquguqukayo, imiksi yamazwibela asebenzisekayo ekhodi, imisebenzi yezibalo ezilula, ukwenza isidleke, kanye nemisebenzi yombala.
Vakashela iwebhusayithi esemthethweni kokuthi http://lesscss.org/ ukuze ufunde kabanzi.
Ukuphatha imibala namavelu ephikseli ku-CSS kungaba buhlungu, ngokuvamile kugcwele ukukopisha nokunamathisela. Hhayi nge-LESS nakuba—nika imibala noma amanani amaphikseli njengokuguquguqukayo futhi uwashintshe kanye.
Lezo zimemezelo ezintathu zerediyasi yomngcele okudingeka uzenze ku-CSS evamile? Manje sezansi emugqeni owodwa ngosizo lwama-mixins, amazwibela wekhodi ongaphinda uwasebenzise noma yikuphi.
Yenza igridi yakho, ihole, futhi ivumelane nezimo kakhulu ngokwenza izibalo undiza ngokusebenza. Okuningi, hlukanisa, engeza, futhi ukhiphe indlela yakho eya ku-CSS sanity.
@linkColor |
#08c | Umbala wombhalo wesixhumanisi esizenzakalelayo | |
@linkColorHover |
darken(@linkColor, 15%) |
Umbala wokuhambisa umbhalo wesixhumanisi esizenzakalelayo |
@gridColumns |
12 |
@gridColumnWidth |
60px |
@gridGutterWidth |
20px |
@fluidGridColumnWidth |
6.382978723% |
@fluidGridGutterWidth |
2.127659574% |
@baseFontSize |
13px | |
@baseFontFamily |
"Helvetica Neue", Helvetica, Arial, sans-serif |
|
@baseLineHeight |
18px |
@black |
#000 | |
@grayDarker |
#222 | |
@grayDark |
#333 | |
@gray |
#555 | |
@grayLight |
#999 | |
@grayLighter |
#eee | |
@white |
#fff |
@blue |
#049cdb | |
@green |
#46a546 | |
@red |
#9d261d | |
@yellow |
#ffc40d | |
@orange |
#f89406 | |
@pink |
#c3325f | |
@purple |
#7a43b6 |
@primaryButtonBackground |
@linkColor |
@placeholderText |
@grayLight |
@navbarHeight |
40px | |
@navbarBackground |
@grayDarker |
|
@navbarBackgroundHighlight |
@grayDark |
|
@navbarText |
@grayLight |
|
@navbarLinkColor |
@grayLight |
|
@navbarLinkColorHover |
@white |
@warningText |
#f3edd2 | |
@warningBackground |
#c09853 | |
@errorText |
#b94a48 | |
@errorBackground |
#f2dede | |
@successText |
#468847 | |
@successBackground |
#dff0d8 | |
@infoText |
#3a87ad | |
@infoBackground |
#d9edf7 |
I-mixin eyisisekelo empeleni ihlanganisa noma ingxenye yamazwibela e-CSS. Abhalwe njengekilasi le-CSS futhi angabizwa noma yikuphi.
- . isici {
- . clearfix ();
- }
Ingxube yepharamitha ifana nje ne-mixin eyisisekelo, kodwa futhi yamukela amapharamitha (yingakho igama) elinamanani azenzakalelayo ongawakhetha.
- . isici {
- . umngcele - irediyasi ( 4px );
- }
Cishe zonke izingxube ze-Bootstrap zigcinwa kuma-mixins.less, insiza emangalisayo .less ifayela elikuvumela ukuthi usebenzise i-mixin kunoma yimaphi amafayela .less kukhithi yamathuluzi.
Ngakho-ke, qhubeka usebenzise ezikhona noma ukhululeke ukungeza ezakho njengoba udinga.
I-Mixin | Amapharamitha | Ukusetshenziswa |
---|---|---|
.clearfix() |
akukho | Engeza kunoma yimuphi umzali ukuze usule okuntantayo ngaphakathi |
.tab-focus() |
akukho | Sebenzisa isitayela sokugxila seWebkit kanye nohlaka oluyindilinga lweFirefox |
.center-block() |
akukho | Misa ngokuzenzakalelayo into yezinga lokuvimba usebenzisamargin: auto |
.ie7-inline-block() |
akukho | Sebenzisa ngaphezu display: inline-block kokujwayelekile ukuze uthole ukwesekwa kwe-IE7 |
.size() |
@height: 5px, @width: 5px |
Setha ngokushesha ubude nobubanzi kulayini owodwa |
.square() |
@size: 5px |
Yakha .size() ukuze usethe ububanzi nobude njengevelu efanayo |
.opacity() |
@opacity: 100 |
Setha, izinombolo eziphelele, iphesenti lokufiphala (isb, "50" noma "75") |
I-Mixin | Amapharamitha | Ukusetshenziswa |
---|---|---|
.placeholder() |
@color: @placeholderText |
Setha placeholder umbala wombhalo wokufakwayo |
I-Mixin | Amapharamitha | Ukusetshenziswa |
---|---|---|
#font > #family > .serif() |
akukho | Yenza i-elementi sebenzisa isitaki sefonti ye-serif |
#font > #family > .sans-serif() |
akukho | Yenza i-elementi sebenzisa isitaki sefonti ye-sans-serif |
#font > #family > .monospace() |
akukho | 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 | Provide a fixed-width (set with @siteWidth ) container for holding your content |
.columns() |
@columns: 1 |
Build a grid column that spans any number of columns (defaults to 1 column) |
.offset() |
@columns: 1 |
Offset a grid column with left margin that spans any number of columns |
.gridColumn() |
none | Make an element float like a grid column |
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 it's original size |
.translate() |
@x: 0, @y: 0 |
Move an element on the x and y planes |
.background-clip() |
@clip |
Crop the backgroud 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 with npm by running the following command:
$ npm install less
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.
Idalwe umfana ofanayo nohlelo lokusebenza lwe-Mac olungekho emthethweni, i-CodeKit iwuhlelo lokusebenza lwe-Mac oluhlanganisa i-LESS, i-SASS, i-Stylus, ne-CoffeeScript.
Uhlelo lokusebenza lwe-Mac, i-Linux, ne-PC lokuhlanganiswa kokudonsa nokudedela kwamafayela angu-LESS. Futhi, ikhodi yomthombo iku-GitHub .