I-Bootstrap yakhelwe phezu kwamagridi wamakholomu angu-12 aphendulayo, izakhiwo, nezingxenye.
I-Bootstrap isebenzisa izici ezithile ze-HTML kanye nezakhiwo ze-CSS ezidinga ukusetshenziswa kwe-HTML5 doctype. Ifake ekuqaleni kwawo wonke amaphrojekthi akho.
- <!DOCTYPE html>
- <html lang = "zu" >
- ...
- </html>
I-Bootstrap isetha isibonisi somhlaba jikelele esiyisisekelo, i-typography, nezitayela zokuxhumanisa. Ngokukhethekile, thina:
margin
emzimbenibackground-color: white;
kubody
@baseFontFamily
, @baseFontSize
, kanye @baseLineHeight
nezibaluli njengesisekelo sethu se-typographic@linkColor
futhi usebenzise isixhumanisi esidwebelayo kuphela:hover
Lezi zitayela zingatholakala ngaphakathi kwe -scaffolding.less .
Nge-Bootstrap 2, ibhulokhi yokusetha kabusha endala yehlisiwe kwavuna i- Normalize.css , iphrojekthi ka- Nicolas Gallagher kanye no- Jonathan Neal ephinde enike amandla i- HTML5 Boilerplate . Ngenkathi sisebenzisa okuningi kwe-Normalize ngaphakathi kwe- reset.less yethu , sisuse ezinye izici ze-Bootstrap.
Isistimu yegridi ye-Bootstrap ezenzakalelayo isebenzisa amakholomu angu-12 , okwenza isiqukathi esibanzi esingu-940px ngaphandle kwezici eziphendulayo ezinikwe amandla. Ngefayela le-CSS eliphendulayo lengeziwe, igridi ijwayela ukuba ngu-724px kanye no-1170px ububanzi kuye ngembobo yakho yokubuka. Ngaphansi kwezimbobo zokubuka ezingu-767px, amakholomu aba uketshezi futhi anqwabelene ngokuqondile.
Ukuze uthole isakhiwo esilula samakholomu amabili, yakha u-a .row
bese wengeza inombolo efanele .span*
yamakholomu. Njengoba lena kuyigridi yamakholomu angu-12, ngayinye .span*
ihlanganisa inombolo yalawo makholomu angu-12, futhi kufanele njalo ihlanganise kufika ku-12 kumugqa ngamunye (noma inani lamakholomu kumzali).
- <div class = "row" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Uma kunikezwe lesi sibonelo, sine .span4
futhi .span8
, okwenza amakholomu ayi-12 esewonke kanye nomugqa ophelele.
Hambisa amakholomu kwesokudla usebenzisa .offset*
amakilasi. Ikilasi ngalinye linyusa umkhawulo wesokunxele wekholomu ngekholomu yonke. Isibonelo, .offset4
ihamba .span4
phezu kwamakholomu amane.
- <div class = "row" >
- <div class = "span4" > ... </div>
- <div class = "span3 offset2" > ... </div>
- </div>
Ukuze uhlanganise okuqukethwe kwakho ngegridi ezenzakalelayo, engeza entsha .row
nesethi .span*
yamakholomu ngaphakathi kwekholomu ekhona .span*
. Imigqa efakwe kusidleke kufanele ifake isethi yamakholomu ahlanganisa inani lamakholomu omzali wayo.
- <div class = "row" >
- <div class = "span9" >
- Ikholomu yeleveli 1
- <div class = "row" >
- <div class = "span6" > Izinga 2 </div>
- <div class = "span3" > Izinga 2 </div>
- </div>
- </div>
- </div>
Isistimu yegridi ewuketshezi isebenzisa amaphesenti esikhundleni samaphikseli kububanzi bekholomu. Inamandla okusabela afanayo nesistimu yethu yegridi engaguquki, iqinisekisa izilinganiso ezifanele zesinqumo esibalulekile sesikrini namadivayisi.
Yenza noma yimuphi umugqa "uketshezi" ngokushintsha .row
ube ngu- .row-fluid
. Amakilasi ekholomu ahlala efana ncamashi, okwenza kube lula ukushintshanisa phakathi kwamagridi angashintshi namanzi.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span8" > ... </div>
- </div>
Isebenza ngendlela efanayo nokulungiswa kwesistimu yegridi engashintshi: engeza .offset*
kunoma iyiphi ikholomu ukuze unciphise ngamakholomu amaningi.
- <div class = "row-fluid" >
- <div class = "span4" > ... </div>
- <div class = "span4 offset2" > ... </div>
- </div>
Amagridi asetshenziswayo asebenzisa isidleke ngendlela ehlukile: ileveli ngayinye ebekwe isidleke yamakholomu kufanele ihlanganise amakholomu angu-12. Lokhu kungenxa yokuthi igridi yoketshezi isebenzisa amaphesenti, hhayi amaphikseli, ukuze imise ububanzi.
- <div class = "row-fluid" >
- <div class = "span12" >
- Uketshezi 12
- <div class = "row-fluid" >
- <div class = "span6" >
- Uketshezi 6
- <div class = "row-fluid" >
- <div class = "span6" > Fluid 6 </div>
- <div class = "span6" > Fluid 6 </div>
- </div>
- </div>
- <div class = "span6" > Fluid 6 </div>
- </div>
- </div>
- </div>
Ihlinzeka ngesakhiwo esivamile sobubanzi obugxilile (futhi esisabela ngokuzithandela) <div class="container">
esidingeka kuphela.
- <umzimba>
- <div class = "container" >
- ...
- </div>
- </umzimba>
Dala uketshezi, ikhasi elinamakholomu amabili— <div class="container-fluid">
elilungele izinhlelo zokusebenza namadokhumenti.
- <div class = "container-fluid" >
- <div class = "row-fluid" >
- <div class = "span2" >
- <!--Okuqukethwe kwebha eseceleni-->
- </div>
- <div class = "span10" >
- <!--Okuqukethwe komzimba-->
- </div>
- </div>
- </div>
Vula i-CSS esabelayo kuphrojekthi yakho ngokufaka i-meta tag efanele neshidi lesitayela elengeziwe ngaphakathi <head>
kwedokhumenti yakho. Uma uhlanganise i-Bootstrap kusuka ekhasini elithi Enza ngendlela oyifisayo, udinga ukufaka kuphela i-meta tag.
- <meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
- <link href = "assets/css/bootstrap-responsive.css" rel = "stylesheet" >
Amakhanda phezulu!I-Bootstrap ayifaki izici eziphendulayo ngokuzenzakalelayo ngalesi sikhathi njengoba kungeyona yonke into edinga ukusabela. Esikhundleni sokukhuthaza onjiniyela ukuthi basuse lesi sici, sikubona kungcono kakhulu ukusivumela njengoba kudingeka.
Imibuzo yemidiya ivumela i-CSS yangokwezifiso ngokususelwe kwinani lemibandela—izilinganiso, ububanzi, uhlobo lokubonisa, njll—kodwa ngokuvamile igxila eduze min-width
futhi max-width
.
Sebenzisa imibuzo yemidiya ngokuzibophezela futhi njengesiqalo kuphela ezithamelini zakho zeselula. Kumaphrojekthi amakhulu, cabanga izisekelo zekhodi ezizinikele hhayi izendlalelo zemibuzo yemidiya.
I-Bootstrap isekela imibuzo embalwa yemidiya efayeleni elilodwa ukuze isize ukwenza amaphrojekthi akho afaneleke kakhudlwana kumadivayisi ahlukene nezinqumo zesikrini. Nakhu okufakiwe:
Ilebula | Ububanzi besakhiwo | Ububanzi bekholomu | Ububanzi be-Gutter |
---|---|---|---|
Isibonisi esikhulu | 1200px nangaphezulu | 70px | 30px |
Okuzenzakalelayo | 980px nangaphezulu | 60px | 20px |
Amathebulethi esithombe | 768px nangaphezulu | 42px | 20px |
Amafoni kumathebulethi | 767px nangaphansi | Amakholomu anoketshezi, abukho ububanzi obungashintshi | |
Amafoni | 480px nangaphansi | Amakholomu anoketshezi, abukho ububanzi obungashintshi |
- /* Ideskithophu enkulu */
- @media ( iminithi - ububanzi : 1200px ) { ... }
- /* Ithebhulethi ye-Portrait ibe yizwe kanye nedeskithophu */
- @media ( iminithi - ububanzi : 768px ) kanye ( ubuningi - ububanzi : 979px ) { ... }
- /* Ifoni ye-landscape ukuze ifane nethebhulethi */
- @media ( ubuningi - ububanzi : 767px ) { ... }
- /* Amafoni we-landscape naphansi */
- @media ( ubuningi - ububanzi : 480px ) { ... }
Ukuze uthole intuthuko esheshayo yeselula, sebenzisa lezi zigaba zensiza ukuze ubonise futhi ufihle okuqukethwe ngedivayisi. Ngezansi kunethebula lamakilasi atholakalayo kanye nomthelela wawo esakhiweni sombuzo wemidiya esinikeziwe (okulebulwe idivayisi). Angatholakala ku responsive.less
.
Ikilasi | Amafoni767px nangaphansi | Izibhebhe979px kuya ku-768px | AmadeskithophuOkuzenzakalelayo |
---|---|---|---|
.visible-phone |
Kubonakala | Kufihliwe | Kufihliwe |
.visible-tablet |
Kufihliwe | Kubonakala | Kufihliwe |
.visible-desktop |
Kufihliwe | Kufihliwe | Kubonakala |
.hidden-phone |
Kufihliwe | Kubonakala | Kubonakala |
.hidden-tablet |
Kubonakala | Kufihliwe | Kubonakala |
.hidden-desktop |
Kubonakala | Kubonakala | Kufihliwe |
Sebenzisa ngokukhawulelwe futhi ugweme ukudala izinguqulo ezihluke ngokuphelele zesayithi elifanayo. Kunalokho, zisebenzise ukuze zigcwalise isethulo sedivayisi ngayinye. Izinsiza ezisabelayo akufanele zisetshenziswe namathebula, futhi ngenxa yalokho azisekelwa.
Shintsha usayizi wesiphequluli sakho noma ulayishe kumadivayisi ahlukene ukuze uhlole amakilasi angenhla.
Omaka abaluhlaza babonisa ukuthi ikilasi liyabonakala endaweni yakho yokubuka yamanje.
Lapha, omaka abaluhlaza bakhombisa ukuthi ikilasi lifihliwe endaweni yakho yokubuka yamanje.