Ewubere bootstrap na grid kọlụm iri na abụọ na-anabata ya. Anyị gụnyekwara nhazi obosara nke edoziri na mmiri dabere na sistemụ ahụ.
Bootstrap na-eji ihe HTML na akụrụngwa CSS nke chọrọ iji HTML5 doctype. Jide n'aka na itinye ya na mmalite nke ibe Bootstrapped ọ bụla na ọrụ gị.
- <!DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
N'ime faịlụ scaffolding.less , anyị na-edobe ihe ngosi zuru ụwa ọnụ, edemede na ụdị njikọ. Kpọmkwem, anyị:
background-color: white;
nabody
@baseFontFamily
, @baseFontSize
, na @baseLineHeight
njirimara dị ka ntọala ederede anyị@linkColor
na ma tinye akara njikọ naanị na:hover
Dị ka nke Bootstrap 2, nrụpụta omenala CSS amalitela iji ihe sitere na Normalize.css , ọrụ Nicolas Gallagher nke na-enyekwa ike HTML5 Boilerplate .
Enwere ike ịhụ nrụpụta ọhụrụ ahụ na reset.less , mana enwere ọtụtụ ihe wepụrụ maka nkenke na izi ezi.
Sistemụ grid ndabara enyere na Bootstrap na-eji kọlụm iri na abụọ na-ewepụta na obosara nke 724px, 940px (ndabara na-enweghị CSS na-anabata gụnyere), yana 1170px. N'okpuru ebe nlele 767px, ogidi ndị ahụ na-aghọ mmiri ma kpokọta na kwụ ọtọ.
- <div klas = "ahịrị" >
- <div klas = "span4" > ... </div>
- <div klas = "span8" > ... </div>
- </div>
Dịka egosiri n'ebe a, enwere ike ịmepụta okirikiri nhọrọ ukwuu yana "ogidi" abụọ, nke ọ bụla na-agbakọ ọnụ ọgụgụ nke kọlụm 12 ntọala anyị kọwara dịka akụkụ nke usoro grid anyị.
- <div klas = "ahịrị" >
- <div klas = "span4" > ... </div>
- <div klas = "span4 offset4" > ... </div>
- </div>
Site na sistemu grid static (na-abụghị mmiri mmiri) na Bootstrap, akwu dị mfe. Ka akwu ọdịnaya gị, dị nnọọ tinye ọhụrụ .row
na set nke .span*
ogidi n'ime otu .span*
kọlụm dị.
Ahịrị akwụkwụ kwesịrị ịgụnye otu kọlụm nke gbakwụnye na ọnụọgụ ogidi nne na nna ya. Dịka ọmụmaatụ, .span3
ekwesịrị idowe ogidi abụọ akwụsịrị n'ime .span6
.
- <div klas = "ahịrị" >
- <div klas = "span6" >
- Ọkwa 1 kọlụm
- <div klas = "ahịrị" >
- <div class = "span3" > Ọkwa 2 </div>
- <div class = "span3" > Ọkwa 2 </div>
- </div>
- </div>
- </div>
Sistemụ grid mmiri na-eji pasentị maka obosara kọlụm kama ịbụ pikselụ edobere. Ọ nwekwara ụdị nzaghachi dị iche iche dị ka sistemụ grid anyị, na-agba mbọ hụ na nha nha kwesịrị ekwesị maka mkpebi ihuenyo na ngwaọrụ.
Mee ka ahịrị ọ bụla nwee mmiri mmiri naanị site na ịgbanwe .row
gaa .row-fluid
. Ogidi ndị ahụ na-adị otu, na-eme ka ọ dị oke nfe ka ọ tụgharịa n'etiti nhazi nke edoziri na nke mmiri.
- <div klas = "ahịhịa-mmiri mmiri" >
- <div klas = "span4" > ... </div>
- <div klas = "span8" > ... </div>
- </div>
Ịgba ọnụ na grid mmiri dịtụ iche: ọnụ ọgụgụ nke kọlụm akwụghị ụgwọ ka ọ dabara na nne na nna. Kama, a na-emegharị kọlụm gị na ọkwa ọ bụla n'ihi na ahịrị ọ bụla na-ewe 100% nke kọlụm nne na nna.
- <div klas = "ahịhịa-mmiri mmiri" >
- <div klas = "span12" >
- Ọkwa 1 nke kọlụm
- <div klas = "ahịhịa-mmiri mmiri" >
- <div class = "span6" > Ọkwa 2 </div>
- <div class = "span6" > Ọkwa 2 </div>
- </div>
- </div>
- </div>
Na-agbanwe agbanwe | Uru ndabara | Nkọwa |
---|---|---|
@gridColumns |
12 | Ọnụọgụ nke ogidi |
@gridColumnWidth |
60px | Obosara nke kọlụm ọ bụla |
@gridGutterWidth |
20px | Oghere adịghị mma n'etiti kọlụm |
Ewubere n'ime Bootstrap bụ ọnụ ọgụgụ dị nta nke mgbanwe maka ịhazi sistemu grid 940px ndabara, edepụtara n'elu. A na-echekwa mgbanwe niile maka grid na variables.less.
Ịgbanwe grid pụtara ịgbanwe mgbanwe atọ @grid*
na ịchịkọta Bootstrap. Gbanwee mgbanwe grid na variables.less ma jiri otu n'ime ụzọ anọ edekọtara iji chịkọta . Ọ bụrụ na ị na-agbakwunye kọlụm ndị ọzọ, jide n'aka na ịtinye CSS maka ndị nọ na grid.less.
Nhazi nke grid na-arụ ọrụ naanị na ọkwa ndabara, grid 940px. Iji jikwaa akụkụ na-anabata nke Bootstrap, ị ga-ahazikwa grid na nzaghachi.less.
Ihe ndabara na dị mfe 940px-obosara, okirikiri nhọrọ ukwuu maka naanị webụsaịtị ma ọ bụ ibe ọ bụla nke otu faịlụ nyere <div class="container">
.
- <ahụ>
- <div klas = "container" >
- ...
- </div>
- </ ahu>
<div class="container-fluid">
na-enye nhazi ihu akwụkwọ na-agbanwe agbanwe, min- na max-obosara, yana akụkụ aka ekpe. Ọ dị mma maka ngwa na docs.
- <div class = "container-fluid" >
- <div klas = "ahịhịa-mmiri mmiri" >
- <div klas = "span2" >
- <!--Ọdịnaya dị n'akụkụ-->
- </div>
- <div klas = "span10" >
- <!--Ọdịnaya nke ahụ-->
- </div>
- </div>
- </div>
Ajụjụ mgbasa ozi na-enye ohere maka CSS omenala dabere n'ọtụtụ ọnọdụ-oke, obosara, ụdị ngosi, wdg-mana na-elekwasịkarị anya gburugburu min-width
yana max-width
.
Jiri ajụjụ mgbasa ozi mee ihe nke ọma na naanị ka mmalite nye ndị na-ege ekwentị gị. Maka nnukwu ọrụ, tụlee ntọala koodu raara onwe ya nye ọ bụghị n'ọkwa nke ajụjụ mgbasa ozi.
Bootstrap na-akwado ọtụtụ ajụjụ mgbasa ozi n'otu faịlụ iji nyere aka mee ka ọrụ gị dabara adaba na ngwaọrụ dị iche iche yana mkpebi ihuenyo. Nke a bụ ihe gụnyere:
Labelụ | Obosara okirikiri | Obosara kọlụm | Obosara gutter |
---|---|---|---|
Smartphones | 480px na n'okpuru | Ogidi mmiri mmiri, enweghị obosara edoziri | |
Smartphones na mbadamba | 767px na n'okpuru | Ogidi mmiri mmiri, enweghị obosara edoziri | |
Mbadamba nkume eserese | 768px na n'elu | 42px | 20px |
Ọdabara | 980px na elu | 60px | 20px |
Nnukwu ngosi | 1200px na elu | 70px | 30px |
Iji hụ na ngwaọrụ gosipụtara ibe na-anabata nke ọma, tinye mkpado meta nlele.
- <meta aha = ọdịnaya "viewport" = "obosara = obosara ngwaọrụ, mbido-ọnụahịa = 1.0" >
Bootstrap anaghị agụnye ajụjụ mgbasa ozi ndị a na-akpaghị aka, mana ịghọta na ịgbakwunye ha dị nnọọ mfe ma chọọ nhazi ntakịrị. Ị nwere nhọrọ ole na ole maka ịgụnye atụmatụ na-anabata nke Bootstrap:
Gịnị kpatara na ị gaghị etinye ya naanị? N'ikwu eziokwu, ọ bụghị ihe niile kwesịrị ịzaghachi. Kama ịgba ndị mmepe ume ka ha wepụ njirimara a, anyị na-eche na ọ kacha mma ime ya.
- /* Ekwentị ala na ala */
- @media ( max - obosara : 480px ) { ... }
- /* Ekwentị ọdịdị ala ka ọ bụrụ mbadamba ihe osise */
- @media ( max - obosara : 767px ) { ... }
- /* Mbadamba ụrọ eserese na odida obodo na desktọpụ */
- @media ( min - obosara : 768px ) na ( max - obosara : 979px ) { ... }
- /* Nnukwu desktọpụ */
- @media ( nkeji - obosara : 1200px ) { ... }
Maka mmepe enyi na enyi mkpanaka ngwa ngwa, jiri klaasị mmekọ ndị a maka igosi na zoo ọdịnaya site na ngwaọrụ.
Jiri na obere ndabere ma zere ịmepụta ụdị dị iche iche nke otu saịtị ahụ. Kama, jiri ha meju ihe ngosi ngwaọrụ ọ bụla.
Dịka ọmụmaatụ, ịnwere ike igosi <select>
mmewere maka ụgbọ mmiri na nyiwe mkpanaka, mana ọ bụghị na mbadamba ma ọ bụ desktọpụ.
Egosiri ebe a bụ tebụl klaasị anyị na-akwado yana mmetụta ha na nhazi ajụjụ mgbasa ozi enyere (nke eji akpọ ya). Enwere ike ịchọta ha na responsive.less
.
Klas | Ekwentị480px na n'okpuru | Mbadamba ụrọ767px na n'okpuru | Desktọpụ768px na n'elu |
---|---|---|---|
.visible-phone |
Na-ahụ anya | Zoro ezo | Zoro ezo |
.visible-tablet |
Zoro ezo | Na-ahụ anya | Zoro ezo |
.visible-desktop |
Zoro ezo | Zoro ezo | Na-ahụ anya |
.hidden-phone |
Zoro ezo | Na-ahụ anya | Na-ahụ anya |
.hidden-tablet |
Na-ahụ anya | Zoro ezo | Na-ahụ anya |
.hidden-desktop |
Na-ahụ anya | Na-ahụ anya | Zoro ezo |
Hagharịa nha ihe nchọgharị gị ma ọ bụ buo ya na ngwaọrụ dị iche iche iji nwalee klas ndị dị n'elu.
Akara akwụkwọ ndụ akwụkwọ ndụ na-egosi na a na-ahụ klaasị na nleba anya gị ugbu a.
N'ebe a, akara akwụkwọ ndụ akwụkwọ ndụ na-egosi na klaasị zoro ezo na nlegharị anya gị ugbu a.