Bootstrap na wan we dɛn bil pan wan 12 kɔlɔm grid we de ansa. Wi dɔn inklud bak fiks- ɛn fluid-wid layout dɛn bays pan da sistɛm de.
Bootstrap de mek yus to HTML elemɛnt ɛn CSS prɔpati dɛn we nid fɔ yuz di HTML5 dokttayp. Mek shɔ se yu put am na di biginin fɔ ɛvri Bootstrapped pej na yu prɔjek.
- <!DƆKTAYP html>
- <html lang = "en" >
- ...
- </html> fɔ di wan dɛn we de
Insay di scaffolding.less fayl, wi de sɛt di bɛsis glob ɔl displei, taypografi, ɛn link stayl dɛn. Speshali, wi:
background-color: white;
pan dibody
@baseFontFamily
, @baseFontSize
, ɛn @baseLineHeight
atribyut dɛn as wi taypografi bays@linkColor
ɛn aplay link ɔndalayn dɛn nɔmɔ pan:hover
As fɔ Bootstrap 2, di tradishɔnal CSS riset dɔn evolv fɔ mek yus to ɛlimɛnt dɛn frɔm Normalize.css , wan prɔjek we Nicolas Gallagher mek we de gi pawa bak to di HTML5 Boilerplate .
Yu kin stil fɛn di nyu riset na reset.less , bɔt wit bɔku ɛlimɛnt dɛn we dɛn dɔn pul fɔ mek i shɔt ɛn fɔ mek i kɔrɛkt.
Di difɔlt grid sistem we dɛn gi na Bootstrap de yuz 12 kɔlɔm dɛn we de rɛnd aut pan width dɛn we na 724px, 940px (difɔlt we nɔ gɛt rispɔnsiv CSS inklud), ɛn 1170px. Dɔŋ 767px viupɔt, di kɔlɔm dɛn kin bi fluid ɛn stak vertikal.
- <div klas = "rɔw" >
- <div klas = "span4" > ... </div>
- <div klas = "span8" > ... </div>
- </div> fɔ di wan dɛn we de
As wi sho ya, dɛn kin mek wan besik layout wit tu "kɔlɔm dɛn", ɛni wan pan dɛn de span wan nɔmba pan di 12 fawndeshɔn kɔlɔm dɛn we wi bin dɔn difayn as pat pan wi grid sistɛm.
- <div klas = "rɔw" >
- <div klas = "span4" > ... </div>
- <div klas = "span4 ɔfset4" > ... </div>
- </div> fɔ di wan dɛn we de
Wit di statik (nɔ-fluid) grid sistem na Bootstrap, nest izi. Fɔ nest yu kɔntinyu, jɔs ad nyu .row
ɛn sɛt fɔ .span*
kɔlɔm dɛn insay wan .span*
kɔlɔm we dɔn de.
Nested rows fɔ gɛt wan sɛt fɔ kɔlɔm dɛn we ad ɔp to di nɔmba fɔ di kɔlɔm dɛn fɔ in mama ɛn papa. Fɔ ɛgzampul, .span3
dɛn fɔ put tu kɔlɔm dɛn we dɛn dɔn nɛst insay wan .span6
.
- <div klas = "rɔw" >
- <div klas = "span6" >
- Level 1 kɔlɔm
- <div klas = "rɔw" >
- <div klas = "span3" > Lɛvɛl 2 </div>
- <div klas = "span3" > Lɛvɛl 2 </div>
- </div> fɔ di wan dɛn we de
- </div> fɔ di wan dɛn we de
- </div> fɔ di wan dɛn we de
Di fluid grid sistem de yuz pasɛnt fɔ kɔlɔm wit instead ɔf fiks piksɛl. I gɛt bak di sem rispɔnsiv vɛryushɔn dɛn lɛk wi fiks grid sistɛm, we de mek shɔ se dɛn gɛt di rayt prɔpɔshɔn fɔ di ki skrin rizɔlt ɛn divays dɛn.
Mek ɛni row fluid jɔs bay we yu chenj .row
to .row-fluid
. Di kɔlɔn dɛn de de di sem, we de mek i supa stret fɔ flip bitwin fiks ɛn fluid layout dɛn.
- <div klas = "rɔw-fluid" >
- <div klas = "span4" > ... </div>
- <div klas = "span8" > ... </div>
- </div> fɔ di wan dɛn we de
Nest wit fluid grids difren likli: di nomba of nest kolm dεm nכ nid fכ mach di mama εn papa. Bifo dat, dɛn kin riset yu kɔlɔm dɛn na ɛni lɛvul bikɔs ɛni rɔw de tek 100% pan di mama ɛn papa kɔlɔm.
- <div klas = "rɔw-fluid" >
- <div klas = "span12" >
- Level 1 na di kɔlɔm
- <div klas = "rɔw-fluid" >
- <div klas = "span6" > Lɛvɛl 2 </div>
- <div klas = "span6" > Lɛvɛl 2 </div>
- </div> fɔ di wan dɛn we de
- </div> fɔ di wan dɛn we de
- </div> fɔ di wan dɛn we de
Di tin dɛn we kin chenj | Difɔlt valyu | Tɔk bɔt |
---|---|---|
@gridColumns |
12 we de tɔk bɔt | Nɔmba fɔ di kɔlɔm dɛn |
@gridColumnWidth |
60px na di pikchɔ | Width fɔ ɛni kɔlɔm |
@gridGutterWidth |
20px we gɛt | Negatif spes bitwin di kɔlɔm dɛn |
Dɛn bil insay Bootstrap na wan anful vɛriɔbul dɛn fɔ kɔstɔmayz di difɔlt 940px grid sistem, we dɛn dɔn rayt ɔp. Ɔl di vɛriɔbul dɛn fɔ di grid dɛn de kip insay vɛriɔbul dɛn.lɛs.
Fɔ chenj di grid min fɔ chenj di tri @grid*
vɛriɔbul dɛn ɛn fɔ kɔmpilayt bak Bootstrap. Chenj di grid vɛriɔbul dɛn insay vɛriɔbul dɛn.lɛs ɛn yuz wan pan di 4 we dɛn we dɛn dɔn dɔkyumɛnt fɔ kɔmpilayt bak . If yu de ad mɔ kɔlɔm dɛn, mek shɔ se yu ad di CSS fɔ di wan dɛn we de na grid.less.
Kastamayzeshɔn fɔ di grid de wok nɔmɔ na di difɔlt lɛvɛl, di 940px grid. Fɔ mek yu kɔntinyu fɔ gɛt di rispɔnsiv aspek dɛn fɔ Bootstrap, yu go gɛt fɔ kɔstɔmayz di grid dɛn bak na responsive.less.
Di difɔlt ɛn simpul 940px-wayd, sɛntrɛd layout fɔ jɔs lɛk ɛni wɛbsayt ɔ pej we wan singl gi <div class="container">
.
- <bɔdi>
- <div klas = "kɔntena" >
- ...
- </div> fɔ di wan dɛn we de
- </bɔdi>
<div class="container-fluid">
gi fleksibul pej strɔkchɔ, min- ɛn maks-wid, ɛn wan lɛft-an saydbar. I fayn fɔ ap ɛn dɔkyumɛnt dɛn.
- <div klas = "kɔntena-fluid" >
- <div klas = "rɔw-fluid" >
- <div klas = "span2" >
- <!--Sidbar kɔntinyu-->
- </div> fɔ di wan dɛn we de
- <div klas = "span10" >
- <!--Bɔdi kɔntinyu-->
- </div> fɔ di wan dɛn we de
- </div> fɔ di wan dɛn we de
- </div> fɔ di wan dɛn we de
Midia kwɛstyɔn dɛn kin alaw fɔ kɔstɔm CSS bay we dɛn de yuz bɔku kɔndishɔn dɛn—rɛsɛsh��n, wit, displei tayp, ɛn ɔda tin dɛn—bɔt bɔku tɛm i kin pe atɛnshɔn rawnd min-width
ɛn max-width
.
Yuz midia kwɛstyɔn dɛn wit rɛspɔnsibiliti ɛn jɔs as stat fɔ yu mobayl ɔdiɛns dɛn. Fɔ big prɔjek dɛn, du tink bɔt dediket kɔd bays ɛn nɔto layers fɔ midia kwɛstyɔn dɛn.
Bootstrap de sɔpɔt wan anful midia kwɛstyɔn dɛn na wan fayl fɔ ɛp fɔ mek yu prɔjek dɛn fit mɔ pan difrɛn divays dɛn ɛn skrin rizɔlt dɛn. Na dis na di tin dɛn we de insay:
Kɔl | Width fɔ layout | Width fɔ di kɔlɔm | Width fɔ di gɔta |
---|---|---|---|
Smatfon dɛn | 480px ɛn dɔŋ ya | Fluid kɔlɔm dɛn, nɔ gɛt fiks wit | |
Smatfon dɛn to tablɛt dɛn | 767px ɛn dɔŋ ya | Fluid kɔlɔm dɛn, nɔ gɛt fiks wit | |
Tablɛt dɛn we de sho pikchɔ dɛn | 768px ɛn ɔp | 42px na di pikchɔ | 20px we gɛt |
Balans | 980px ɛn ɔp | 60px na di pikchɔ | 20px we gɛt |
Big big displei | 1200px ɛn ɔp | 70px na di pikchɔ | 30px na di pikchɔ |
Fɔ mek shɔ se divays dɛn de sho di pej dɛn we de ansa fayn fayn wan, put di viewport mɛta tag.
- <meta nem = "viupɔt" kɔntinyu = "wid=divays-wid, initial-skel=1.0" >
Bootstrap nɔ de inklud dɛn midia kwɛstyɔn ya ɔtomɛtik wan, bɔt fɔ ɔndastand ɛn ad dɛn rili izi ɛn i nid fɔ sɛtup smɔl. Yu gɛt sɔm opshɔn dɛn fɔ put di rispɔnsiv ficha dɛn na Bootstrap:
Wetin mek yu nɔ jɔs put am insay? Fɔ tru, nɔto ɔltin nid fɔ bi pɔsin we de ansa. Bifo wi ɛnkɔrej di wan dɛn we de mek am fɔ pul dis ficha, wi kin tink se i bɛtɛ fɔ mek dɛn ebul fɔ yuz am.
- /* Landskɛp fon dɛn ɛn dɔŋ */
- @media ( maks - width : 480px ) { ... }.
- /* Landskɛp fon fɔ pɔtrɛt tablɛt */
- @media ( maks - width : 767px ) { ... }.
- /* Portret tablɛt to land skay ɛn dɛsktɔp */
- @media ( min - width : 768px ) ɛn ( maks - wid : 979px ) { ... }
- /* Big big dɛsktɔp */
- @media ( min - width : 1200px ) { ... } Wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan wan
Fɔ mek yu ebul fɔ divɛlɔp di mobayl kwik kwik wan, yuz dɛn bɛsik yutiliti klas ya fɔ sho ɛn ayd kɔntinyu bay divays.
Yuz am smɔl ɛn nɔ mek difrɛn difrɛn vɛshɔn dɛn fɔ di sem sayt. Bifo dat, yuz dɛn fɔ kɔmplit di prɛzɛntɛnshɔn we de na ɛni divays.
Fɔ ɛgzampul, yu kin sho wan <select>
ɛlimɛnt fɔ nav na mobayl layout, bɔt nɔto pan tablɛt ɔ dɛsktɔp.
Dɛn sho ya na wan tebul fɔ di klas dɛn we wi de sɔpɔt ɛn dɛn ifɛkt pan wan givɛn midia kwɛstyɔn layout (we dɛn lɛbul bay divays). Yu kin fɛn dɛn na responsive.less
.
Klas | Fɔn dɛn480px ɛn dɔŋ ya | Tablɛt dɛn767px ɛn dɔŋ ya | Dɛsktɔp dɛn768px ɛn ɔp |
---|---|---|---|
.visible-phone |
Wi kin si am | Ayd | Ayd |
.visible-tablet |
Ayd | Wi kin si am | Ayd |
.visible-desktop |
Ayd | Ayd | Wi kin si am |
.hidden-phone |
Ayd | Wi kin si am | Wi kin si am |
.hidden-tablet |
Wi kin si am | Ayd | Wi kin si am |
.hidden-desktop |
Wi kin si am | Wi kin si am | Ayd |
Risayz yu brɔwza ɔ lod am na difrɛn divays dɛn fɔ tɛst di klas dɛn we de ɔp.
Grin chɛkmak dɛn de sho se di klas de sho na di say we yu de si naw.
Na ya, grɛn chɛkmak dɛn de sho se klas de ayd na di say we yu de si naw.