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.
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)
Izitayela zokuphendula ze-Bootstrap zakhelwe ukuthi ziphendule, indlela evame ukubizwa ngokuthi yi -mobile-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 yemidiya. 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. Ngezinye izikhathi, lokhu kukhipha kucace ngokusebenza nangokomqondo ukuze kusetshenziswe futhi kusekelwe kunokubhala kabusha ukusebenza okubalulekile okuvela kuzingxenye zethu. Silwela ukunciphisa le ndlela, kodwa sizoyisebenzisa ngezikhathi ezithile.
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.
Ngakho-ke, 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.
Kunezikali ezimbili z-index
ku-Bootstrap—izakhi ezingaphakathi kwengxenye nezingxenye zembondela.
- 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
ithi:hover
,2
ngu:active
/.active
, futhi ,3
ingu: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.
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 ayihleliwe futhi isebenza njengebhafa encane phakathi kwezitayela zethu nezitayela zangokwezifiso zephrojekthi yakho.
Ingxenye ngayinye eyimbondela inyusa z-index
inani layo kancane ngendlela yokuthi izimiso ze-UI ezivamile zivumele izici ezigxilile zomsebenzisi noma ezihambisa phezulu ukuthi 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 .
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 esijwayelekile sikunikeza umsebenzi omningi.
Lesi simiso siyi-JavaScript API yethu yekilasi lokuqala 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.
Amakilasi ezinsiza—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.
Nakuba kungenzeki ngaso sonke isikhathi, silwela ukugwema ukuba negoma ngokweqile ezimfuneko zethu ze-HTML zezingxenye. Ngakho-ke, sigxila emakilasini angawodwa kuzikhethi zethu ze-CSS futhi sizame ukugwema abakhethi bezingane ngokushesha ( ~
). Lokhu kukunikeza ukuguquguquka okwengeziwe ekusebenziseni kwakho futhi kusiza ukugcina i-CSS yethu ilula futhi ingacacisi kangako.