Bootstrap yubatswe kumurongo wa 12 winkingi. Twashizemo kandi imiterere- na fluid-ubugari imiterere ishingiye kuri sisitemu.
Bootstrap ikoresha ibintu bya HTML nibintu bya CSS bisaba gukoresha inyandiko ya HTML5. Wemeze kubishyira mu ntangiriro ya page yose ya Bootstrapped mumushinga wawe.
- <! DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
Muri scafolding.idafite dosiye, dushiraho ibyingenzi byerekanwa kwisi, imyandikire, hamwe nuburyo bwo guhuza. By'umwihariko, twe:
background-color: white;
kuribody
@baseFontFamily
,, @baseFontSize
na @baseLineHeight
Ibiranga nkimyandikire yacu@linkColor
kandi ushyire kumurongo uhuza gusa:hover
Kuva kuri Bootstrap 2, gusubiramo gakondo kwa CSS byahindutse kugirango bikoreshe ibintu biva muri Normalize.css , umushinga wa Nicolas Gallagher nawo uha ingufu Boilerplate ya HTML5 .
Gusubiramo gushya birashobora kuboneka muri reset.less , ariko hamwe nibintu byinshi byavanyweho kubugufi nukuri.
Sisitemu isanzwe ya gride yatanzwe muri Bootstrap ikoresha inkingi 12 zitanga ubugari bwa 724px, 940px (isanzwe idafite CSS yitabiriwe irimo), na 1170px. Munsi ya 767px yo kureba, inkingi zihinduka amazi kandi zihagaze neza.
- <div class = "umurongo" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Nkuko bigaragara hano, imiterere shingiro irashobora gushirwaho hamwe n "" inkingi "ebyiri, buri kimwe kizenguruka umubare winkingi 12 zifatizo twasobanuye nkigice cya sisitemu ya gride.
- <div class = "umurongo" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset4" > ... </div>
- </div>
Hamwe na sisitemu ya static (idafite amazi) muri sisitemu ya Bootstrap, guterana biroroshye. Kugirango ushire ibikubiyemo, gusa ongeraho ibishya .row
kandi ushireho .span*
inkingi murwego ruriho .span*
.
Imirongo yatoranijwe igomba gushiramo urutonde rwinkingi ziyongera kumubare winkingi zababyeyi. Kurugero, .span3
inkingi ebyiri zegeranye zigomba gushyirwa muri a .span6
.
- <div class = "umurongo" >
- <div class = "span6" >
- Urwego 1
- <div class = "umurongo" >
- <div class = "span3" > Urwego 2 </div>
- <div class = "span3" > Urwego 2 </div>
- </div>
- </div>
- </div>
Sisitemu ya grid sisitemu ikoresha ijanisha ryubugari bwinkingi aho kuba pigiseli ihamye. Ifite kandi ibisubizo bitandukanye nkibisubizo bya gride sisitemu ihamye, byemeza neza ibipimo byingenzi bya ecran n'ibikoresho.
Kora umurongo uwo ariwo wose utemba uhinduye .row
kuri .row-fluid
. Inkingi zigumaho neza, bigatuma zoroha cyane guhindagurika hagati yimiterere ihamye kandi itemba.
- <div class = "umurongo-utemba" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Gutera hamwe na gride ya fluid iratandukanye gato: umubare winkingi zometse ntukeneye guhuza nababyeyi. Ahubwo, inkingi zawe zisubirwamo kuri buri rwego kuko buri murongo ufata 100% yinkingi yababyeyi.
- <div class = "umurongo-utemba" >
- <div class = "span12" >
- Urwego 1 rwinkingi
- <div class = "umurongo-utemba" >
- <div class = "span6" > Urwego 2 </div>
- <div class = "span6" > Urwego 2 </div>
- </div>
- </div>
- </div>
Birahinduka | Agaciro gasanzwe | Ibisobanuro |
---|---|---|
@gridColumns |
12 | Umubare winkingi |
@gridColumnWidth |
60px | Ubugari bwa buri nkingi |
@gridGutterWidth |
20px | Umwanya mubi hagati yinkingi |
Yubatswe muri Bootstrap nintoki zimpinduka zo guhitamo sisitemu ya gride ya 940px isanzwe, yanditse hejuru. Ibihinduka byose kuri gride bibitswe mubihinduka.less.
Guhindura gride bisobanura guhindura ibintu bitatu @grid*
bihinduka no gusubiramo Bootstrap. Hindura grid ihindagurika mubihinduka.nta kandi ukoreshe bumwe muburyo bune bwanditse kugirango usubiremo . Niba wongeyeho inkingi nyinshi, menya neza ko wongera CSS kubari muri grid.less.
Guhindura gride ikora gusa kurwego rusanzwe, gride ya 940px. Kugirango ugumane ibintu bisubiza muri Bootstrap, ugomba kandi guhitamo gride mubisubizo.less.
Mburabuzi kandi yoroshye 940px-ubugari, imiterere igizwe nurubuga rwose cyangwa page yatanzwe numwe <div class="container">
.
- <body>
- <div class = "kontineri" >
- ...
- </div>
- </body>
<div class="container-fluid">
itanga urupapuro rworoshye, min- na max-ubugari, hamwe nibumoso. Nibyiza kuri porogaramu na doc.
- <div class = "kontineri-fluid" >
- <div class = "umurongo-utemba" >
- <div class = "span2" >
- <! - Ibirimo kuruhande ->
- </div>
- <div class = "span10" >
- <! - Ibiri mu mubiri ->
- </div>
- </div>
- </div>
Ibibazo byibitangazamakuru byemerera CSS yihariye ishingiye kubintu byinshi - ibipimo, ubugari, ubwoko bwerekana, nibindi - ariko mubisanzwe byibanda hafi min-width
na max-width
.
Koresha ibibazo byitangazamakuru ushishoze kandi gusa nkintangiriro kubakurikirana mobile. Kubikorwa binini, tekereza kode yabigenewe ntabwo ari ibice byibibazo byibitangazamakuru.
Bootstrap ishyigikira urutonde rwibibazo byitangazamakuru muri dosiye imwe kugirango ifashe gukora imishinga yawe neza kubikoresho bitandukanye no gukemura ibyemezo. Dore ibirimo:
Ikirango | Ubugari bw'imiterere | Ubugari bw'inkingi | Ubugari |
---|---|---|---|
Amaterefone | 480px no hepfo | Inkingi zamazi, nta bugari bwagenwe | |
Terefone igendanwa | 767px no hepfo | Inkingi zamazi, nta bugari bwagenwe | |
Ibishushanyo mbonera | 768px no hejuru | 42px | 20px |
Mburabuzi | 980px no hejuru | 60px | 20px |
Kugaragaza binini | 1200px no hejuru | 70px | 30px |
Kugirango ibikoresho byerekana impapuro zishubije neza, shyiramo icyerekezo cya meta tag.
- <meta izina = "kureba" ibirimo = "ubugari = igikoresho-ubugari, intangiriro-igipimo = 1.0" >
Bootstrap ntabwo ihita ikubiyemo ibyo bibazo byitangazamakuru, ariko kubyumva no kubyongera biroroshye cyane kandi bisaba gushiraho bike. Ufite amahitamo make yo gushiramo ibiranga ibisubizo bya Bootstrap:
Ubona gute ushizemo gusa? Ukuri kuvugwe, ntabwo ibintu byose bigomba kwitabwaho. Aho gushishikariza abitezimbere gukuraho iyi miterere, dusanga ari byiza kuyishoboza.
- / * Amaterefone yimiterere no hepfo * /
- @media ( max - ubugari : 480px ) { ... }
- / * Terefone igendanwa kugirango igaragaze tablet * /
- @media ( max - ubugari : 767px ) { ... }
- / * Igishushanyo cyerekana ibishushanyo mbonera na desktop * /
- @media ( min - ubugari : 768px ) na ( max - ubugari : 979px ) { ... }
- / * Ibiro binini * /
- @media ( min - ubugari : 1200px ) { ... }
Kugirango iterambere ryihuta-ryimikorere, koresha aya masomo yingirakamaro yo kwerekana no guhisha ibirimo kubikoresho.
Koresha muburyo buke kandi wirinde gukora verisiyo zitandukanye zurubuga rumwe. Ahubwo, koresha kugirango wuzuze buri gikoresho cyerekana.
Kurugero, urashobora kwerekana ikintu <select>
cya nav kumiterere ya mobile, ariko ntabwo iri kuri tablet cyangwa desktop.
Hano herekanwa imbonerahamwe yamasomo dushyigikiye ningaruka zabyo kubibazo byatanzwe mubitangazamakuru (byashyizweho nigikoresho). Bashobora kuboneka muri responsive.less
.
Icyiciro | Terefone480px no hepfo | Ibinini767px no hepfo | Ibiro768px no hejuru |
---|---|---|---|
.visible-phone |
Biboneka | Hihishe | Hihishe |
.visible-tablet |
Hihishe | Biboneka | Hihishe |
.visible-desktop |
Hihishe | Hihishe | Biboneka |
.hidden-phone |
Hihishe | Biboneka | Biboneka |
.hidden-tablet |
Biboneka | Hihishe | Biboneka |
.hidden-desktop |
Biboneka | Biboneka | Hihishe |
Hindura amashusho yawe cyangwa umutwaro kubikoresho bitandukanye kugirango ugerageze ibyiciro byavuzwe haruguru.
Icyatsi kibisi cyerekana ko icyiciro kigaragara muburyo bwawe bwo kureba.
Hano, icyatsi kibisi cyerekana ko urwego rwihishe muburyo bwawe bwo kureba.