Bootstrap na bil pan 12-kɔlɔm grid dɛn we de ansa, layout dɛn, ɛn kɔmpɔnɛnt dɛn we de ansa.
Bootstrap de mek yus to sɔm HTML ɛlimɛnt dɛn ɛn CSS prɔpati dɛn we nid fɔ yuz di HTML5 dɔktayp. Put am insay di biginin fɔ ɔl yu prɔjek dɛn.
- <!DƆKTAYP html>
- <html lang = "en" >
- ...
- </html> fɔ di wan dɛn we de
Bootstrap de sɛt di bɛsis glob ɔl displei, taypografi, ɛn link stayl dɛn. Speshali, wi:
margin
pan di bɔdibackground-color: white;
pan dibody
@baseFontFamily
, @baseFontSize
, ɛn @baseLineHeight
atribyut dɛn as wi taypografik bays@linkColor
ɛn aplay link ɔndalayn dɛn nɔmɔ pan:hover
Yu kin fɛn dɛn stayl ya insay skɔf.less .
Wit Bootstrap 2, di ol riset blɔk dɔn drɔp in favɔrit fɔ Normalize.css , wan prɔjek we Nicolas Gallagher ɛn Jonathan Neal du we de gi pawa bak to di HTML5 Boilerplate . Pan ɔl we wi de yuz bɔku pan Normalize insay wi reset.less , wi dɔn pul sɔm ɛlimɛnt dɛn spɛshal fɔ Bootstrap.
Di difɔlt Bootstrap grid sistem de yuz 12 kɔlɔm dɛn , we de mek fɔ wan 940px waid kɔntena we nɔ gɛt rispɔnsiv ficha dɛn we dɛn dɔn ɛnabul. Wit di rispɔnsiv CSS fayl we dɛn ad, di grid de adap fɔ bi 724px ɛn 1170px waid dipen pan yu viupɔt. Dɔŋ 767px viupɔt, di kɔlɔm dɛn kin bi fluid ɛn stak vertikal.
Fɔ simpul tu kɔlɔm layout, mek wan .row
ɛn ad di rayt nɔmba fɔ di .span*
kɔlɔm dɛn. As dis na 12 kɔlɔm grid, ɛni wan pan .span*
dɛn span wan nɔmba pan dɛn 12 kɔlɔm dɛn de, ɛn dɛn fɔ ad 12 ɔltɛm fɔ ɛni row (ɔ di nɔmba fɔ di kɔlɔm dɛn na di mama ɔ papa).
- <div klas = "rɔw" >
- <div klas = "span4" > ... </div>
- <div klas = "span8" > ... </div>
- </div> fɔ di wan dɛn we de
Given dis ɛgzampul, wi gɛt .span4
ɛn .span8
, we de mek fɔ 12 totɛl kɔlɔm dɛn ɛn wan kɔmplit row.
Muv kɔlɔm dɛn to di rayt say yuz .offset*
klas dɛn. Ɛni klas de mek di lɛft say na wan kɔlɔm go ɔp bay wan ol kɔlɔm. Fɔ ɛgzampul, .offset4
i de muv .span4
oba 4 kɔlɔm dɛn.
- <div klas = "rɔw" >
- <div klas = "span4" > ... </div>
- <div klas = "span3 ɔfset2" > ... </div>
- </div> fɔ di wan dɛn we de
Fɔ nest yu kɔntinyu wit di difɔlt grid, ad nyu .row
ɛn sɛt fɔ .span*
kɔlɔm dɛn insay wan .span*
kɔlɔm we dɔn de. Di row dɛn we dɛn dɔn nɛst fɔ gɛt wan sɛt fɔ kɔlɔm dɛn we de ad to di nɔmba fɔ di kɔlɔm dɛn we in mama ɔ papa gɛt.
- <div klas = "rɔw" >
- <div klas = "span9" >
- Level 1 kɔlɔm
- <div klas = "rɔw" >
- <div klas = "span6" > 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 instead ɔf piksɛl fɔ kɔlɔm wit. I gɛt di sem rispɔnsiv kapabiliti dɛn we wi fiks grid sistɛm gɛt, 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" bay we yu chenj .row
to .row-fluid
. Di kɔlɔm klas dɛn kin de di sem, we kin mek i izi fɔ flip bitwin fiks ɛn fluid grid dɛn.
- <div klas = "rɔw-fluid" >
- <div klas = "span4" > ... </div>
- <div klas = "span8" > ... </div>
- </div> fɔ di wan dɛn we de
I de wok di sem we lɛk di fiks grid sistɛm ɔfset: ad .offset*
to ɛni kɔlɔm fɔ ɔfset bay da bɔku kɔlɔm de.
- <div klas = "rɔw-fluid" >
- <div klas = "span4" > ... </div>
- <div klas = "span4 ɔfset2" > ... </div>
- </div> fɔ di wan dɛn we de
Fluid grid dɛn de yuz nɛst difrɛn we: ɛni nɛst lɛvɛl fɔ kɔlɔm dɛn fɔ ad te to 12 kɔlɔm dɛn. Dis na bikɔs di fluid grid de yuz pasɛnt, nɔto piksɛl, fɔ sɛt di wit.
- <div klas = "rɔw-fluid" >
- <div klas = "span12" >
- Fluid we de insay 12
- <div klas = "rɔw-fluid" >
- <div klas = "span6" >
- Fluid we de insay 6
- <div klas = "rɔw-fluid" >
- <div klas = "span6" > Fluid 6 </div>
- <div klas = "span6" > Fluid 6 </div>
- </div> fɔ di wan dɛn we de
- </div> fɔ di wan dɛn we de
- <div klas = "span6" > Fluid 6 </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
Gi wan kɔmɔn fiks-wid (ɛn opshɔnal rispɔnsiv) layout wit ɔl <div class="container">
we dɛn nid.
- <bɔdi>
- <div klas = "kɔntena" >
- ...
- </div> fɔ di wan dɛn we de
- </bɔdi>
Krio wan fluid, tu-kolom pej wit <div class="container-fluid">
—great fɔ aplikeshɔn ɛn doks.
- <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
On responsive CSS in yu projɛkt bay we yu put di rayt mɛta tag ɛn ɔda staylshit insay di <head>
ɔf yu dɔkyumɛnt. If yu dɔn kɔmpilayt Bootstrap frɔm di Customize pej, yu nid fɔ jɔs put di mɛta tag.
- <meta nem = "viupɔt" kɔntinyu = "wid=divays-wid, initial-skel=1.0" >
- <link href = "asɛt/css/butstrap-rɛspɔnsiv.css" rel = "staylshit" >
Hed dɛn de ɔp!Bootstrap nɔ inklud rispɔnsiv ficha dɛn bay difɔlt dis tɛm as nɔto ɔltin nid fɔ rispɔnsiv. 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 as nid 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 |
---|---|---|---|
Big big displei | 1200px ɛn ɔp | 70px na di pikchɔ | 30px na di pikchɔ |
Balans | 980px ɛn ɔp | 60px na di pikchɔ | 20px we gɛt |
Tablɛt dɛn we de sho pikchɔ dɛn | 768px ɛn ɔp | 42px na di pikchɔ | 20px we gɛt |
Fɔn dɛn to tablɛt dɛn | 767px ɛn dɔŋ ya | Fluid kɔlɔm dɛn, nɔ gɛt fiks wit | |
Fɔn dɛn | 480px ɛn dɔŋ ya | Fluid kɔlɔm dɛn, nɔ gɛt fiks wit |
- /* 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
- /* Portret tablɛt to land skay ɛn dɛsktɔp */
- @media ( min - width : 768px ) ɛn ( maks - wid : 979px ) { ... }
- /* Landskɛp fon fɔ pɔtrɛt tablɛt */
- @media ( maks - width : 767px ) { ... }.
- /* Landskɛp fon dɛn ɛn dɔŋ */
- @media ( maks - width : 480px ) { ... }.
Fɔ mek yu ebul fɔ divɛlɔp di mobayl kwik kwik wan, yuz dɛn yutiliti klas ya fɔ sho ɛn ayd tin dɛn bay divays. Dis dɔŋ ya na wan tebul fɔ di klas dɛn we de ɛ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ɛn767px ɛn dɔŋ ya | Tablɛt dɛn979px to 768px | Dɛsktɔp dɛnBalans |
---|---|---|---|
.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 |
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. Rispɔnsiv yutiliti dɛn nɔ fɔ yuz wit tebul dɛn, ɛn as a so dɛn nɔ de sɔpɔt dɛn.
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.