Indlela
Funda mayelana nemigomo eyisiqondiso, amasu, namasu asetshenziswa ukwakha nokunakekela i-Bootstrap ukuze ukwazi ukwenza ngendlela oyifisayo kalula futhi uyinwebe ngokwakho.
Nakuba amakhasi okuqalisa ehlinzeka ngohambo olusethulo lwephrojekthi kanye nalokho ekunikezayo, lo mbhalo ugxile ekutheni kungani senza izinto esizenzayo ku-Bootstrap. Ichaza ifilosofi yethu yokwakha kuwebhu ukuze abanye bafunde kithi, banikele nathi, futhi usisize sithuthuke.
Uyabona into engezwakali kahle, noma mhlawumbe engenziwa kangcono? Vula udaba —singathanda ukuxoxa nawe ngalo.
Isifinyezo
Sizocwila kulokhu ngakunye kulo lonke, kodwa ezingeni eliphezulu, nakhu okuqondisa indlela yethu yokwenza.
- Izingxenye kufanele ziphendule futhi zihambe kuqala
- Izingxenye kufanele zakhiwe ngesisekelo sekilasi futhi zinwetshwe ngamakilasi okulungisa
- Izifunda zengxenye kufanele zithobele isikali senkomba engu-z evamile
- Noma nini lapho kunokwenzeka, khetha ukusetshenziswa kwe-HTML ne-CSS kune-JavaScript
- Uma kunokwenzeka, sebenzisa izinsiza phezu kwezitayela zangokwezifiso
- Noma nini lapho kungenzeka, gwema ukuphoqelela izimfuneko eziqinile ze-HTML (abakhethi bezingane)
Iyasabela
Izitayela zokuphendula ze-Bootstrap zakhelwe ukuthi ziphendule, indlela evame ukubizwa ngokuthi iselula-first . Sisebenzisa leli gama kumadokhumenti ethu futhi sivumelana kakhulu nalo, kodwa ngezinye izikhathi lingaba banzi kakhulu. Yize kungezona zonke izingxenye okufanele ziphendule ngokuphelele ku-Bootstrap, le ndlela yokusabela imayelana nokunciphisa ukukhipha kwe-CSS ngokukuphusha ukuthi ungeze izitayela njengoba imbobo yokubuka iba nkulu.
Ku-Bootstrap yonkana, uzobona lokhu ngokucacile emibuzweni yethu yabezindaba. Ezimweni eziningi, sisebenzisa min-width
imibuzo eqala ukusebenza endaweni ethile yokuphumula futhi idlulele ezindaweni eziphakeme kakhulu. Isibonelo, i-a .d-none
isebenza ukusuka min-width: 0
kuye kokungapheli. Ngakolunye uhlangothi, u-a .d-md-none
uyasebenza ukusuka endaweni yokuphumula emaphakathi naphezulu.
Ngezinye izikhathi sizosebenzisa max-width
lapho inkimbinkimbi yengxenye yemvelo ikudinga. Kwesinye isikhathi, lokhu kukhipha kucace ngokusebenza nangokwengqondo ukuze kusetshenziswe futhi kusekelwe kunokubhala kabusha ukusebenza okubalulekile okuvela kuzingxenye zethu. Silwela ukunciphisa le ndlela, kodwa sizoyisebenzisa ngezikhathi ezithile.
Amakilasi
Ngaphandle kokuthi Ukuqalisa Kabusha kwethu, ishidi lesitayela lokujwayelekile lesiphequluli esiphambanayo, zonke izitayela zethu zihlose ukusebenzisa amakilasi njengabakhethi. Lokhu kusho ukwehlukana nabakhethi bohlobo (isb, input[type="text"]
) kanye namakilasi omzali angaphandle (isb, .parent .child
) enza izitayela zicace kakhulu ukuthi zingabhalwa ngaphezulu kalula.
Kanjalo, izingxenye kufanele zakhiwe ngesigaba sesisekelo esihlala amapheya avamile, okungafanele akhishwe. Ngokwesibonelo, .btn
futhi .btn-primary
. Sisebenzisa .btn
kuzo zonke izitayela ezijwayelekile ezifana display
, padding
, kanye border-width
. Sibe sesisebenzisa izilungisi ezifana .btn-primary
nokwengeza umbala, umbala wangemuva, umbala womngcele, njll.
Amakilasi okulungisa kufanele asetshenziswe kuphela uma kunezinto eziningi noma amanani azoshintshwa kuzo zonke izinhlobo eziningi. Izilungisi azidingeki ngaso sonke isikhathi, ngakho-ke qiniseka ukuthi empeleni ulondoloza imigqa yekhodi futhi uvimbele ukukhishwa okungadingekile uma uzidala. Izibonelo ezinhle zezilungisi amakilasi ethu ombala wetimu nokuhlukahluka kosayizi.
z-inkomba izikali
Kunezikali ezimbili z-index
ku-Bootstrap—izakhi ezingaphakathi kwengxenye nezingxenye zembondela.
Izakhi zengxenye
- Ezinye izingxenye ku-Bootstrap zakhiwe ngezinto ezigqagqene ukuvimbela imingcele ephindwe kabili ngaphandle kokulungisa
border
isakhiwo. Isibonelo, amaqembu ezinkinobho, amaqembu okokufaka, nokuhlukanisa amagama. - Lezi zingxenye zabelana
z-index
ngesilinganiso esijwayelekile0
sokudlula3
. 0
iyinto ezenzakalelayo (eyokuqala),1
ingu-:hover
,2
ngu:active
/.active
, futhi3
iyi-:focus
.- Le ndlela ihambisana nalokho esikulindele kokubaluleke kakhulu komsebenzisi. Uma i-elementi igxilile, ibonwa futhi ekunakeni komsebenzisi. Ama-elementi asebenzayo asendaweni yesibili ngenxa yokuthi akhombisa isimo. I-Hover ingeyesithathu ngobukhulu ngoba ikhombisa inhloso yomsebenzisi, kodwa cishe noma yini ingahanjiswa phezulu.
Izingxenye zembondela
I-Bootstrap ihlanganisa izingxenye ezimbalwa ezisebenza njengembondela yohlobo oluthile. Lokhu kufaka phakathi, ngokulandelana okuphezulu kakhulu z-index
, okwehliswayo, ama-navbar angashintshi futhi anamathelayo, ama-modal, amathiphu wamathuluzi, nama-popover. Lezi zingxenye zinesilinganiso sazo z-index
esiqala ku- 1000
. Le nombolo yokuqala ikhethwe ngokungafanele futhi isebenza njengesivimbeli esincane phakathi kwezitayela zethu nezitayela zangokwezifiso zephrojekthi yakho.
Ingxenye ngayinye eyimbondela inyusa inani layo z-index
kancane ngendlela yokuthi izimiso ze-UI ezivamile zivumele izici ezigxilile zomsebenzisi noma ezihambisa phezulu ukuze zihlale zibonakala ngaso sonke isikhathi. Isibonelo, i-modal iwukuvinjwa kwedokhumenti (isb, awukwazi ukuthatha noma yisiphi esinye isenzo ulondoloze isenzo se-modal), ngakho sibeka lokho ngaphezu kwama-navbar ethu.
Funda kabanzi ngalokhu z-index
ekhasini lethu lesakhiwo .
I-HTML ne-CSS ngaphezu kwe-JS
Noma nini lapho kunokwenzeka, sikhetha ukubhala i-HTML ne-CSS phezu kwe-JavaScript. Ngokuvamile, i-HTML ne-CSS yanda kakhulu futhi ifinyeleleka kubantu abaningi bawo wonke amazinga okuhlangenwe nakho ahlukene. I-HTML ne-CSS nazo ziyashesha esipheqululini sakho kune-JavaScript, futhi isiphequluli sakho ngokuvamile sikunikeza umsebenzi omningi.
Lo mgomo uyi-JavaScript API yethu yekilasi lokuqala esebenzisa data
izibaluli. Awudingi ukubhala cishe noma iyiphi i-JavaScript ukuze usebenzise ama-plugin ethu e-JavaScript; esikhundleni salokho, bhala i-HTML. Funda kabanzi ngalokhu ekhasini lethu lokubuka konke le-JavaScript .
Okokugcina, izitayela zethu zakhela phezu kokuziphatha okuyisisekelo kwezinto ezivamile zewebhu. Noma nini lapho kunokwenzeka, sikhetha ukusebenzisa lokho okunikezwa isiphequluli. Isibonelo, ungabeka .btn
ikilasi cishe kunoma iyiphi i-elementi, kodwa ama-elementi amaningi awanikezi noma yiliphi inani le-semantic noma ukusebenza kwesiphequluli. Ngakho esikhundleni salokho, sisebenzisa u <button>
-s no- <a>
s.
Okufanayo kuya ezingxenyeni eziyinkimbinkimbi. Nakuba singase sibhale i-plugin yethu yokuqinisekisa ifomu ukuze sengeze amakilasi entweni yomzali ngokusekelwe esimweni sokungenayo, ngaleyo ndlela kusivumela ukuba senze isitayela sombhalo sithi bomvu, sikhetha ukusebenzisa :valid
/ :invalid
izakhi-mbumbulu zonke isiphequluli esisinikeza zona.
Izinsiza
Amakilasi osizo—ababengabasizi ku-Bootstrap 3—bangabambisene abanamandla ekulweni nokuqunjelwa kwe-CSS nokusebenza kabi kwekhasi. Isigaba sosizo ngokuvamile siwukumataniswa kwenani lesakhiwo okukodwa, okungaguquleki okuvezwe njengesigaba (isb., .d-block
simelela display: block;
). Isikhalazo sabo esiyinhloko ijubane lokusetshenziswa ngenkathi ubhala i-HTML futhi ukhawulela inani le-CSS yangokwezifiso okufanele uyibhale.
Ngokukhethekile mayelana ne-CSS yangokwezifiso, izinsiza zingasiza ukulwa nokukhulisa usayizi wefayela ngokunciphisa amapheya akho enani lezakhiwo avame ukuphindaphindwa abe amakilasi awodwa. Lokhu kungaba nomthelela omkhulu esikalini kumaphrojekthi akho.
I-HTML eguquguqukayo
Nakuba kungenzeki ngaso sonke isikhathi, silwela ukugwema ukuba negoma ngokweqile ezimfuneko zethu ze-HTML zezingxenye. Ngakho, sigxila emakilasini angawodwa kuzikhethi zethu ze-CSS futhi sizame ukugwema abakhethi bezingane abasheshayo ( >
). Lokhu kukunikeza ukuguquguquka okwengeziwe ekusebenziseni kwakho futhi kusiza ukugcina i-CSS yethu ilula futhi ingacacisi kangako.
Izimiso zekhodi
I- Code Guide (kusuka kumdali we-Bootstrap, @mdo) ibhala ukuthi siyibhala kanjani i-HTML yethu ne-CSS kuyo yonke i-Bootstrap. Icacisa imihlahlandlela yokufometha okuvamile, okuzenzakalelayo komqondo ojwayelekile, izakhiwo nezibaluli oda, nokuningi.
Sisebenzisa i -Stylint ukuze siphoqelele lawa mazinga nokunye okwengeziwe ku-Sass/CSS yethu. Ukulungiselelwa kwethu kwe-Stylelint ngokwezifiso kuwumthombo ovulekile futhi kuyatholakala ukuze abanye bawusebenzise futhi banwebe.
Sisebenzisa i -vnu-jar ukuze siphoqelele i-HTML ejwayelekile neye-semantic, kanye nokuthola amaphutha avamile.