Bootstrap yubatswe kumurongo 12 winkingi ya gride, imiterere, nibigize.
Bootstrap ikoresha ibintu bimwe na bimwe bya HTML hamwe na CSS isaba gukoresha inyandiko ya HTML5. Shyiramo intangiriro yimishinga yawe yose.
- <! DOCTYPE html>
- <html lang = "en" >
- ...
- </html>
Bootstrap ishyiraho ibanze kwisi yose, imyandikire, hamwe nuburyo bwo guhuza. By'umwihariko, twe:
margin
umubiribackground-color: white;
kuribody
@baseFontFamily
,, @baseFontSize
na @baseLineHeight
Ibiranga nkimyandikire yacu@linkColor
kandi ushyire kumurongo uhuza gusa:hover
Ubu buryo bushobora kuboneka muri scafolding.less .
Hamwe na Bootstrap 2, guhagarika gusubiramo bishaje byavanyweho kugirango Normalize.css , umushinga wa Nicolas Gallagher na Jonathan Neal nawo uha ingufu Boilerplate ya HTML5 . Mugihe dukoresha byinshi Mubisanzwe muri reset.less , twakuyeho ibintu bimwe na bimwe kuri Bootstrap.
Ubusanzwe Bootstrap grid sisitemu ikoresha inkingi 12 , ikora kubintu 940px yagutse idafite ibintu byitabiriwe byashobotse. Hamwe na dosiye ya CSS yitabiriwe yongeyeho, gride ihuza kuba 724px na 1170px mugari ukurikije uko ubona. Munsi ya 767px yo kureba, inkingi zihinduka amazi kandi zigahagarara neza.
Kuburyo bworoshye bubiri inkingi, kora a .row
hanyuma wongere umubare ukwiye .span*
winkingi. Nkuko iyi ari 12-inkingi ya gride, buriwese .span*
uzenguruka umubare wizo nkingi 12, kandi ugomba guhora wongeyeho 12 kuri buri murongo (cyangwa umubare winkingi mubabyeyi).
- <div class = "umurongo" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Urebye uru rugero, dufite .span4
kandi .span8
, dukora inkingi 12 zose hamwe numurongo wuzuye.
Himura inkingi iburyo ukoresheje .offset*
amasomo. Buri cyiciro cyongera ibumoso bwinkingi yinkingi yose. Kurugero, .offset4
yimuka .span4
hejuru yinkingi enye.
- <div class = "umurongo" >
- <div class = "span4" > ... </div>
- <div class = "span3 offset2" > ... </div>
- </div>
Kugirango ushire ibikubiyemo hamwe na gride isanzwe, ongeramo ibishya .row
kandi ushireho .span*
inkingi muburyo buriho .span*
. Imirongo yatoranijwe igomba gushiramo urutonde rwinkingi ziyongera kumubare winkingi zababyeyi.
- <div class = "umurongo" >
- <div class = "span9" >
- Urwego 1
- <div class = "umurongo" >
- <div class = "span6" > Urwego 2 </div>
- <div class = "span3" > Urwego 2 </div>
- </div>
- </div>
- </div>
Sisitemu ya grid sisitemu ikoresha ijanisha aho kuba pigiseli kubugari bwinkingi. Ifite ubushobozi bumwe bwo gusubiza nka sisitemu ya gride ya sisitemu ihamye, yemeza ibipimo bikwiye bya ecran ya ecran n'ibikoresho.
Kora umurongo uwo ariwo wose "fluid" uhindura .row
kuri .row-fluid
. Inkingi ibyiciro bigumaho kimwe, byoroshye guhinduranya hagati ya gride itunganijwe kandi itemba.
- <div class = "umurongo-utemba" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Ikora kimwe na grid sisitemu ihamye yo guhagarika: ongeraho .offset*
inkingi iyo ari yo yose kugirango uhagarike nizo nkingi nyinshi.
- <div class = "umurongo-utemba" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset2" > ... </div>
- </div>
Imiyoboro ya fluide ikoresha ibyari bitandukanye: buri cyiciro cyateganijwe cyinkingi kigomba kongerwaho inkingi 12. Ibi ni ukubera ko gride ya fluid ikoresha ijanisha, ntabwo ari pigiseli, mugushiraho ubugari.
- <div class = "umurongo-utemba" >
- <div class = "span12" >
- Amazi 12
- <div class = "umurongo-utemba" >
- <div class = "span6" >
- Amazi 6
- <div class = "umurongo-utemba" >
- <div class = "span6" > Amazi 6 </div>
- <div class = "span6" > Amazi 6 </div>
- </div>
- </div>
- <div class = "span6" > Amazi 6 </div>
- </div>
- </div>
- </div>
Itanga imiterere-yubugari rusange (kandi birashoboka ko isubiza) imiterere <div class="container">
ikenewe gusa.
- <body>
- <div class = "kontineri" >
- ...
- </div>
- </body>
Kora amazi, urupapuro rwinkingi ebyiri hamwe <div class="container-fluid">
-gukoresha 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>
Fungura CSS yitabira mumushinga wawe ushizemo meta ikwiye hamwe nurupapuro rwinyongera murwego <head>
rwinyandiko yawe. Niba warateguye Bootstrap kuva kurupapuro rwa Customize, ukeneye gushyiramo meta gusa.
- <meta izina = "kureba" ibirimo = "ubugari = igikoresho-ubugari, intangiriro-igipimo = 1.0" >
- <ihuza href = "umutungo / css / bootstrap-yitabira.css" rel = "urupapuro rwerekana "
Umutwe!Bootstrap ntabwo ikubiyemo ibintu byitondewe kubisanzwe muriki gihe kuko ntabwo byose bigomba kuba byitabirwa. Aho gushishikariza abitezimbere gukuraho iyi miterere, dusanga ari byiza kuyishoboza nkuko bikenewe.
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 byitangazamakuru.
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 |
---|---|---|---|
Kugaragaza binini | 1200px no hejuru | 70px | 30px |
Mburabuzi | 980px no hejuru | 60px | 20px |
Ibishushanyo mbonera | 768px no hejuru | 42px | 20px |
Terefone kuri tableti | 767px no hepfo | Inkingi zamazi, nta bugari bwagenwe | |
Terefone | 480px no hepfo | Inkingi zamazi, nta bugari bwagenwe |
- / * Ibiro binini * /
- @media ( min - ubugari : 1200px ) { ... }
- / * Igishushanyo cyerekana ibishushanyo mbonera na desktop * /
- @media ( min - ubugari : 768px ) na ( max - ubugari : 979px ) { ... }
- / * Terefone igendanwa kugirango igaragaze tablet * /
- @media ( max - ubugari : 767px ) { ... }
- / * Amaterefone yimiterere no hepfo * /
- @media ( max - ubugari : 480px ) { ... }
Kugirango iterambere ryihuta-ryimikorere, koresha aya masomo yingirakamaro kugirango werekane kandi uhishe ibiri kubikoresho. Hasi nimbonerahamwe yamasomo aboneka ningaruka zabyo kubibazo byatanzwe mubitangazamakuru (byashyizweho nigikoresho). Bashobora kuboneka muri responsive.less
.
Icyiciro | Terefone767px no hepfo | Ibinini979px kugeza 768px | IbiroMburabuzi |
---|---|---|---|
.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 |
Koresha muburyo buke kandi wirinde gukora verisiyo zitandukanye zurubuga rumwe. Ahubwo, koresha kugirango wuzuze buri gikoresho cyerekana. Ibikorwa byingirakamaro ntibigomba gukoreshwa hamwe nameza, kandi nkibyo ntibishyigikiwe.
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.