Indlela
Funda malunga nemigaqo esisikhokelo, amaqhinga, kunye nobuchule obusetyenzisiweyo ukwakha nokugcina i-Bootstrap ukuze wenze lula kwaye uyandise ngokwakho.
Ngelixa amaphepha okuqalisa abonelela ngotyelelo lwentshayelelo yeprojekthi kunye nento ebonelela ngayo, olu xwebhu lujolise ekubeni kutheni sisenza izinto esizenzayo kwiBootstrap. Icacisa ifilosofi yethu ekwakheni kwiwebhu ukuze abanye bafunde kuthi, babe negalelo nathi, kwaye basincede siphucule.
Uyabona into engavakali kakuhle, okanye mhlawumbi inokwenziwa ngcono? Vula umba othile— singathanda ukuwuxubusha nawe.
Siza kuntywila kwinto nganye kwezi ngakumbi kulo lonke, kodwa kwinqanaba eliphezulu, nantsi into ekhokela indlela yethu.
- Amacandelo kufuneka aphendule kwaye ahamba-phambili
- Amacandelo kufuneka akhiwe ngodidi olusisiseko kwaye andise ngeeklasi zesilungisi
- Amacandelo kufuneka athobele isikali esiqhelekileyo sika-z-index
- Nanini na kunokwenzeka, khetha ukuphunyezwa kweHTML kunye neCSS ngaphezu kweJavaScript
- Nanini na kunokwenzeka, sebenzisa izinto eziluncedo ngaphezu kwezitayile eziqhelekileyo
- Nanini na kunokwenzeka, kuphephe ukunyanzelisa iimfuno ezingqongqo zeHTML (abakhethi babantwana)
Izitayile zokuphendula zeBootstrap zakhelwe ukusabela, indlela edla ngokubizwa ngokuba yi -mobile-first . Sisebenzisa eli gama kumaxwebhu ethu kwaye sivumelana kakhulu nalo, kodwa ngamanye amaxesha linokuba banzi kakhulu. Ngelixa ingelilo lonke icandelo ekufuneka liphendule ngokupheleleyo kwiBootstrap, le ndlela yokuphendula imalunga nokunciphisa i-CSS ngaphezulu ngokukutyhala ukuba wongeze izitayile njengoko indawo yokujonga isiya iba nkulu.
Kuyo yonke iBootstrap, uyakubona oku ngokucacileyo kwimibuzo yethu yemithombo yeendaba. Kwiimeko ezininzi, sisebenzisa min-width
imibuzo eqala ukusebenza kwindawo ethile yekhefu kwaye iqhubele phambili kwiindawo eziphezulu. Umzekelo, i-a .d-none
isebenza ukusuka min-width: 0
kwi-infinity. Kwelinye icala, i-a .d-md-none
isebenza ukusuka kwindawo yokuphumla ephakathi ukuya phezulu.
Ngamanye amaxesha siya kusebenzisa max-width
xa ukuntsokotha kwendalo kwecandelo kulifuna. Ngamanye amaxesha, ezi zinto zigqithisiweyo zisebenza kwaye zicacile ngokwasengqondweni ukuphumeza kunye nenkxaso kunokubhala kwakhona umsebenzi ongundoqo kumacandelo ethu. Sizama ukunciphisa le ndlela, kodwa siya kuyisebenzisa amaxesha ngamaxesha.
Ngaphandle kweReboot yethu, iphepha lesitayile esinqumlezayo, zonke izitayile zethu zijolise ekusebenziseni iiklasi njengabakhethi. Oku kuthetha ukukhokela ngokucacileyo kubakhethi bodidi (umzekelo, input[type="text"]
) kunye neeklasi zabazali ezingaphandle (umzekelo, .parent .child
) ezenza izimbo zicace kakhulu ukuba zingabhalwa ngaphezulu ngokulula.
Ngokunjalo, amacandelo kufuneka akhiwe ngodidi olusisiseko olunezindlu eziqhelekileyo, ezingamele zigqitywe ngababini bexabiso lepropathi. Ngokomzekelo, .btn
kwaye .btn-primary
. Sisebenzisa .btn
kuzo zonke izimbo eziqhelekileyo ezifana display
, padding
kunye border-width
. Emva koko sisebenzisa izilungisi ezithanda .btn-primary
ukongeza umbala, umbala ongasemva, umbala womda, njl.
Iiklasi zesilungisi kufuneka zisetyenziswe kuphela xa kukho iipropati ezininzi okanye amaxabiso aza kutshintshwa kuzo zonke iindidi ezininzi. Izilungisi azisoloko ziyimfuneko, ke qiniseka ukuba ngokwenene ugcina imigca yekhowudi kwaye unqanda ukugqwesa okungeyomfuneko xa uyidala. Imizekelo emihle yezilungisi ziiklasi zethu zemibala yomxholo kunye nokwahluka kobukhulu.
Kukho z-index
izikali ezibini kwi-Bootstrap-izinto ngaphakathi kwecandelo kunye nezinto ezingaphezulu.
- Amanye amacandelo kwiBootstrap akhiwe ngezinto ezidlulanayo ukukhusela imida ephindwe kabini ngaphandle kokuguqula
border
ipropati. Umzekelo, amaqela amaqhosha, amaqela egalelo, kunye nokwakhiwa kwamaphepha. z-index
La macandelo abelana ngomlinganiselo oqhelekileyo we-0
through3
.0
ayigqibekanga (eyokuqala),1
ngu:hover
,2
ngu:active
/.active
, kwaye ,3
ngu:focus
.- Le ndlela ihambelana nolindelo lwethu oluphezulu lwabasebenzisi. Ukuba into igxininisiwe, ibonwa kwaye ijongwe ngumsebenzisi. Izinto ezisebenzayo zezesibini phezulu kuba zibonisa imeko. IHover yeyesithathu ephezulu kuba ibonisa injongo yomsebenzisi, kodwa phantse nantoni na inokushukunyiswa.
I-Bootstrap ibandakanya amacandelo amaninzi asebenza njengesigqubuthelo sohlobo oluthile. Oku kuquka, ngokolandelelwano z-index
lwezona ziphezulu , ukwehla, ii-navbar ezizinzileyo nezincangathi, iimodyuli, izixhobo zokusebenza, kunye neepopovers. La malungu anomlinganiselo wawo z-index
oqala ku 1000
. Eli nani lokuqala alikhethi kwaye lisebenza njengesithinteli esincinci phakathi kwezitayile zethu kunye nezimbo zesiko leprojekthi yakho.
Indawo nganye eyalekayo inyusa z-index
ixabiso lalo kancinane ngendlela yokuba imigaqo ye-UI eqhelekileyo ivumela izinto ezigxilwe kumsebenzisi okanye ezishukumayo ukuba zihlale zibonwa ngamaxesha onke. Umzekelo, imodal luthintelo loxwebhu (umzekelo, awukwazi ukuthatha naliphi na elinye inyathelo gcina isenzo semodali), ngoko sibeka ngaphezulu kwe navbar zethu.
Funda ngakumbi malunga noku kwiphepha lethu z-index
loyilo .
Nanini na kunokwenzeka, sikhetha ukubhala iHTML kunye neCSS ngaphezulu kweJavaScript. Ngokubanzi, i-HTML kunye neCSS zixhaphakile kwaye zifikeleleka kubantu abaninzi kuwo onke amanqanaba amava ahlukeneyo. I-HTML kunye neCSS zikwakhawuleza kwibrawuza yakho kuneJavaScript, kwaye isikhangeli sakho sibonelela ngomsebenzi omkhulu kuwe.
Lo mgaqo udidi lwethu lokuqala lweJavaScript API data
ziimpawu. Awudingi ukubhala phantse nayiphi na iJavaScript ukusebenzisa iiplagi zethu zeJavaScript; endaweni yoko, bhala iHTML. Funda ngakumbi malunga noku kwiphepha lethu lokujonga iJavaScript .
Okokugqibela, izitayile zethu zakhela kwiindlela zokuziphatha zezinto eziqhelekileyo zewebhu. Nanini na xa kunokwenzeka, sikhetha ukusebenzisa into ebonelelwa ngumkhangeli zincwadi. Umzekelo, ungabeka .btn
iklasi phantse kuyo nayiphi na into, kodwa uninzi lweziqalelo aluboneleli ngexabiso lesemantic okanye ukusebenza kwesikhangeli. Ngoko endaweni yoko, sisebenzisa u <button>
-s kunye no- <a>
s.
Okufanayo kuya kumacandelo anzima ngakumbi. Ngelixa sinokubhala eyethu iplagi yokuqinisekisa ifom ukongeza iiklasi kwinto yomzali esekwe kwimeko yegalelo, ngaloo ndlela kusivumela ukuba sibhale isitayile sombhalo sithi bomvu, sikhetha ukusebenzisa i- :valid
/ :invalid
pseudo-elements sonke isikhangeli sisinika sona.
Iiklasi eziluncedo-ababefudula bengabancedi kwi-Bootstrap 3-bangumhlobo onamandla ekulweni i-CSS bloat kunye nokusebenza kakubi kwephepha. Udidi olusebenzisekayo lukholisa ukuba yinto enye, engenakuguquleka yexabiso lepropathi edityaniswe njengodidi (umzekelo, .d-block
imele display: block;
). Isibheno sabo esiphambili sisantya sokusetyenziswa ngelixa ubhala i-HTML kunye nokunciphisa inani le-CSS yesiko ekufuneka uyibhale.
Ngokukodwa malunga ne-CSS yesiko, izinto eziluncedo zinokunceda ukulwa nokwandisa ubungakanani befayile ngokunciphisa izibini zexabiso lepropathi eliqhele ukuphindwa kwiiklasi enye. Oku kunokuba nefuthe elimangalisayo kwisikali kwiiprojekthi zakho.
Nangona kungasoloko kusenzeka, sizama ukunqanda ukuba ngqongqo ngokugqithisileyo kwiimfuno zethu zeHTML kumacandelo. Ngaloo ndlela, sigxininisa kwiiklasi ezingatshatanga kubakhethi bethu beCSS kwaye sizame ukuphepha abakhethi babantwana abakhawulezayo ( >
). Oku kukunika ukuguquguquka ngakumbi ekuphumezeni kwakho kwaye kunceda ukugcina i-CSS yethu ilula kwaye ingacaciswanga kangako.